External font not applied by CSS - javafx-8

I'm trying to create icon buttons. I've downloaded them from flaticon.com and had them exported as icon font files, which includes a TTF file.
In my css file I specify the external font as:
#font-face {
font-family: flaticon;
src: url('/flaticon/flaticon.ttf');
}
I've defined a button class that should use this font as follows:
.flaticon-button {
-fx-font-size: 90px;
-fx-font-family: flaticon;
-fx-padding: 10px;
}
My code applies the styleclass as follows:
Button button = new Button("\ue000");
button.getStyleClass().add("flaticon-button");
But unfortunately it doesn't show the expected icon.
When I load the font in my code and set it explicitly the correct icon is shown:
Font font = Font.loadFont(this.getClass().getResource("/flaticon/flaticon.ttf").toExternalForm() , 90d);
Button button = new Button("\ue000");
button.setFont(font);
I'm obviously overlooking something small, but despite how many examples I browse on the internet, or how long I stare at Oracle's CSS documentation I can't see what.
So, what is wrong with my CSS declaration and usage?

Thanks to the comment of rossum, I realized it it might have something to do with the URL not resolving to the class, as Class.getResource() does.
By loading the font in the main, before it is references by the code, it seems to be resolved. I guess there is no other way, but it seems to be a bit of a hack to me.

Related

How do I have unicode characters on GitHub shown as characters rather than icons?

I decided to write the name of this plugin of mine as vim↪softwrap rather than vim-softwrap, but, to my surprise, GitHub shows the ↪ as an icon:
What can I do to avoid that?
I'm not sure whether it's GitHub that is doing it or it's the Markdown specification to require it.
It looks like it's using these fonts (the css selector being the <g-emoji> tag that it inserts around emoji unicode):
g-emoji {
font-family: "Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";
}
If you save this as an html file an open it, you will see the same thing:
<p style='font-family: "Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol"'>↪</p>

How to change font size on blog pages created on Github using JekyllNow

I created a Github.io blog using JekyllNow. JekyllNow allows you to create it fully on the web itself without having git or Ruby installed locally. i.e. everything was done without any local operation.
I am using the minimal theme. My page is created but the font seems very big. How do I change the font sizes on the page?
If there is a way to make it proportional, that would be even better - i.e. i.e. not just the default font size but also, H1, H2 etc sizes also are proportionally smaller.
Normally we edit the file style.scss located at the root of the jekyll instance.
body {
font-family: "Times New Roman", Times, serif;
}
But, if you are using the default Jekyll theme "Minima", you will have to edit the file minima.scss instead of the style.scss.
So, To change the default font size definition you need to reset the value of `$base-font-size'
$base-font-size: 16px !default;
Also you can change the default font definition itself by resetting the value of $base-font-family variable,
$base-font-family: "PT Serif", serif;
You will also need to remove the !default; suffix at the end of this setting for the new font to be applicable.

Ionic React: How to integrate custom fonts and icon set

I’m new with Ionic React and I’m looking for the correct way to integrate custom fonts and a custom icon set into my project, so that it’s working on all platforms as intended.
Custom Icon set
My goal is to make my custom icons work with IonIcon so that I can use the default styling options like “size” and the CSS variables (e…g --ioinc-stroke-weight).
What I did so far:
I added the icon set (all icons are svgs) into “public/assets/customicons/”
I imported IonIcon into my components where needed
Integrated the (e.g. )
So far the icons are displayed as intended and custom attributes “size” is working.
But, I’m not able to set the icon color or stroke-width programmatically. All the icons have set a default attributes (e.g. < g fill=“none” fill-rule=“evenodd” stroke="#092A5E" stroke-linecap=“round” stroke-linejoin=“round” stroke-width=“8” >). Even if I remove those default attributes, I’m not able to set them via CSS variables
Question 1: Is “public/assets/customicons/” the correct folder to store the icons?
Question 2: How can I make it work that I can change the color of the icon via CSS?
Custom Font
Goal: I want that the custom font is shown on all platforms
What I did so far:
Added the custom fonts in “src/assets/fonts/”
Created a “fonts.css” in “src/theme/” where I integrated the font via “#font-face”
#font-face {
font-family: ‘FONTNAME’;
src: url(’…/assets/fonts/FONTNAME.ttf’);
font-style: normal;
font-weight: 400;
font-display: swap;
}
assigned the font to differnet elements
Question 1: Is this the correct folder to store the custom fonts? (I wasn’t able to do the same when the custom font was saved under “public/assets/fonts/” like the icon set)
Unfortunately, I wasn’t able to find any docs, tutorials or posts on any of these topics.
Thanks for your help!

Resize by default TinyMCE

I'm using TinyMCE for the first time, and I love it, but is a bit closed.
I'd like to get images resized by default, this is, when adding an image, put it by default on 300px width, for example (then the user can make it bigger or smaller dragging).
I don't know where to touch! Is there a command within the lists of images (the js you can attach to make TinyMCE show a list of images)? Or I have to hack css? Or I have to dive into TinyMCE code?
Thank you in advance
Marc
If you are OK with changing code files then proceed as follows
Open tiny_mce/plugins/advimage/js/image.js
Locate insertAndClose : function()
Insert after
var ed = tinyMCEPopup.editor, ......;
if(f.width.value == ""){
f.width.value = 300;
}
Hope it helps!
There are several options. I would go the css way. Check out the tinycme init configuration setting content_css. Using an additioanl own css file enables you to setthe width of images to 300px easily.

iOS 4.2+ webfont (ttf) 's bold font-weight rendering bug

This one is quite specify: specify ttf font rendering font-weight:bold incorrectly on iOS mobile safari, open demo site with iphone/ipad with iOS 4.2/4.3 Beta 3 or above:
(this is Reenie+Beanie from google fonts)
http://jsbin.com/ojeqe3/16/
Screen capture
You see the bold font look double rendered. This is not significant for small and medium font size, but quite significant for large font-size / zoom in
My friend will report this bug to apple. However, anything he can do to solve the bug? (kill the text-adjust is not OK)
Update:
This one is not fixed in iOS5.
The best solution I know for the problem will be
Use font-weight:normal (as shown in demo)
Use either -webkit-text-stroke or text-shadow to make it look "bold" (plus iPad only css - body prefix added by js, not only media query)
Had the same issue with an h1 inheriting the font-weight: bold; from a parent class. Just overwrite the inherited style with a font-weight: normal;
It seems that Mobile Safari has a buggy way of rendering faux styles with font-faces. For bold it will double the text and offset, and with most fonts it would go unnoticed, but with thin font faces it will look like double vision.
In your case the Reenie Beanie does not include a bold style, and if you're using them as heading without changing the font-weight to normal or 400 it will render the bold weight "faux styled".
Please do note that using faux styles is generally buggy in some browsers and not only in Mobile Safari.
Solution 1. Use the appropriate font-weight
So the best solution is to change the font-weight to the one that Google Fonts provide, quick fix below:
h1, h2, h3, h4, h5, strong, b {
font-weight: 400;
}
/* or font-weight: normal */
Solution 2. Use a font that does provide the bold/italic style that you want
The other solution is to pick a font from a web font archive that does include a bold style. Alternatives in Google Fonts that look a lot like Reenie Beanie and are "bolder" would be e.g. Gochi Hand, Sunshiney, or Permanent Marker.
Solution 3. Fake the faux using other means
If you really insist on wanting a faux bold style you can try using a thin text-shadow or text stroke.
don't use the 'bolder' or 'bold' tag. they aren't necessary if you are using a specific weighted webfont.
I had the same problem. It went away when I removed any mention of font-weight.
Try applying this css rule:
-webkit-font-smoothing: antialiased;