Comments (6)
I wonder if the Arial font actually includes the ⌘
character, or if other native apps (including web browsers) automatically detect special characters and fall back to a different font when needed. I know that emoji are stored in a separate font, so certain other special characters might be too.
from openfl.
The looped square char (U+2318) is not included with Arial.
https://www.fileformat.info/info/unicode/font/arial/list.htm
Chrome for instance falls back to the Cambria Math font which includes it.
https://www.fileformat.info/info/unicode/font/cambria_math/list.htm
from openfl.
As far as I know, OpenFL's TextField
doesn't currently have a mechanism for falling back to another font for any kind of special character.
Interestingly, Flash Player and AIR on macOS (just a quick test... I didn't try on Windows or Linux) can render the ⌘
character when specifying Arial (I also saw it with Verdana and Courier New), so it seems to have some kind of fallback capability.
from openfl.
https://www.fileformat.info/info/unicode/char/2318/fontsupport.htm
If you have a swf asset I am sure I used to have an html textfield and manually put all the characters in it and set to embedded. You can then on populating content convert to html.
Found this.
https://divillysausages.com/2011/02/17/as3-font-embedding-masterclass/
It seems to mention that flash treats some char as symbols so the fall back mentioned for pure flash.
If you manage to get the font in your code you could try something like
var textString = '....';// your text here
var tf = new TextField( 100, 100 );
addChild(tf);
var beginArial = '<FONT FACE="Arial" SIZE="12" COLOR="#000000" LETTERSPACING="0" KERNING="0">';
var beginCambria = '<FONT FACE="Cambria" SIZE="12" COLOR="#000000" LETTERSPACING="0" KERNING="0">';
tf.htmlText = beginArial + textString.split('⌘').join( '<\FONT>' + beginCambria + '⌘' + '<\FONT>' + beginArial ) + </FONT>;
another way is with CSS styles setup in code either by trying to reference them in the flash html.
Another approach that may work something like..
tf.defaultTextFormat = arialTextFormat;
var arr = [];
var i = 0;
while(true) {
// becareful of infinite loops should be ok but put a max iter in there on first run.
var j = textString.indexOf('⌘',0);
if( j == -1 ){
break;
} else {
arr.push( j );
i = j +1;
}
}
for( i in 0...arr.length ){
tf.setTextFormat( cambriaTextFormat, arr[i], arr[i+1] );
}
Not tried any of this recently and not sure I even have any of my as3 textmangling still to hand and unsure how well will work on openfl but you will need to embed required font/chars.
To check the font of an html textfield that for instance you embedded in the swf with an onscreen textfield you can trace it to help with setting up your dynamically added textfields.
from openfl.
signed distance field fonts would allow you to use images with characters you want without trying to hack a char into an existing TTF. Ceramic uses SDF by default I think.
I made a start on porting a simple html one to pure haxe but yet to get round to tackling the gl aspect as likely need to tidy it up, unsure what SDF support openfl/lime has, but in theory the webgl ported if simple enough would be made to work with lime c++/js via a shader. It would likely lack much of flash textfields features as layout is always hard to do very well.
from openfl.
Scanline provided the information I needed; here is the same sample on Windows, but using the Inconsolata font.
from openfl.
Related Issues (20)
- Add support for 2.5D properties like rotationX and rotationY
- Sounds over a certain length do not play properly. HOT 3
- [html5] FileReferenceList doesn't dispatch Event.CANCEL HOT 1
- DropShadowFilter renders incorrectly when applied onto a TextField HOT 1
- OpenFL is compatible with old devices on WeChat IOS, which can cause`__scissorRectangle` An error occurred during off screen rendering;
- FlashPlayer does not change its size HOT 4
- [HTML5] Display looks bad when it is not a scale HOT 1
- Custom fonts don't support bold or italic variants on Windows HOT 3
- Uncaught TypeError: Cannot read properties of null (reading 'duration') - Sound.hx:761
- TextField does not handle <img> on platforms other than Flash HOT 3
- The Hashlink profiler does not work with OpenFL HOT 5
- Linking to `utest` or `munit` breaks HTML5 target HOT 1
- how do i use the core opengl core profile on macOS haxe? HOT 5
- Support for uniform structures in GLSL
- WebSocket APIs
- preserveDrawingBuffer attribute support.
- iOS Runpath issue
- Holding down keyboard keys on MacOS brings up special character menu HOT 5
- Threading with bitmap datas converted to textures silent crashes the game HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from openfl.