Why safari does not allow new FontFace() with font family name starting with a number - safari

My JS code loads fonts creating a new FontFace object for each font. It seems that safari cannot handle new FontFace() call when font family name, first argument, starts with a number.
Tried to create a FontFace object in safari versions prior to v14 developer tools console, the same behaviour could be observed, new FontFace('test', 'url("test/path")') works just fine, but new FontFace('1test', 'url("test/path")') does throw an error "SyntaxError: The string did not match the expected pattern"
How would it be possible to save fonts with font family name starting with a number?

Related

ArcGIS for JavaScript 4.21 Emoji in textSymbol

Hello I'm using ArcGIS for JavaScript 4.21
I was abel to create a Graphic with poligon. I want to se a title to polygon so I have created another object above it. That object have a type "text" it is a SimpleText object. And it works fine with simple text with letters. But if someone use a Emoji in text it returns a this exception:
[esri.views.2d.engine.webgl.TextureManager] k {name: 'mapview-invalid-resource', details: undefined, message: "Couldn't find font josefin-slab-regular. Falling back to Arial Unicode MS Regular"}
I think it is because of unicode, but in prevous version 3.32, I was able to use Emojies. I can't find out a solution to deal with it. So I want to ask if anyone has encountered this problem. Thank you.
here is my example in code pan.
Problem is on row 144. If you change text: "👩" to text: "Helo" it works.
Tomáš, I don't think that will work.
In 4x, the supported fonts to use with TextSymbol on graphics are limited to the list at https://developers.arcgis.com/javascript/latest/labeling/#fonts-for-featurelayer-csvlayer-and-streamlayer.
In 3x, it worked quite differently, so the font support for TextSymbol was dependent on that specific machines general browser/OS support of fonts.

The font properties looks similar but looks and feel is different in two pdf documents

I have a PDF template document given by my client as a reference. My application has to create it. When i compared the PDF generated by my application and the template given by the client i could see the look and feel are slightly different.I opened it in Adobe acrobat pro dc, i could still see the font properties are same. Please see the link below to see the PDFs header i created which has the above mentioned issue.
Please see the image:
I have the font properties defined in xml as below.This will be unmarshalled later.
<font name="Arial Narrow" id="blackBold" fsize="12" type="bold" rgb="0,0,0"/>
I have the different font type defined in a map like below,
fontAndAlignmentMap.put("bold", 1);
//Internally this will be resolved to-->com.itextpdf.text.Font.BOLD = 1;
The itext Font will be created from an unmarshalled xml font object as below:
FontFactory.registerDirectories();
com.itextpdf.text.Font itextFont =
FontFactory.getFont(sbcFont.getName(), sbcFont.getFsize(), fontAndAlignmentMap.get(sbcFont.getType()), new BaseColor(r,g,b));
The 10 page pdf document have different fonts and formatting.The Statically defined fonts are unmarshalled and loaded into the itextFontMap as shown below.
itextFontMap.put(sbcFont.getId(), itextFont);
sbcFont.getId() are "blackBold","blackRegular" etc.Depends on the use the appropriate font will be pulled from this map.
Phrase pSbc = new Phrase("Summary of Benefits and Coverage:",
SBCMappingSingletonBuilder.itextFontMap.get("blackBold"));`
Phrase pSbcDesc = new Phrase(
" What this Plan Covers & What You Pay For Covered Services",
SBCMappingSingletonBuilder.itextFontMap.get("blackRegular"));
When i printed the family name of the com.itextpdf.text.Font object.
blackBold.getFamilyname() :Arial Narrow
blackRegular.getFamilyname() :Arial Narrow
This is what printed from the code.
sbcFont.getName() :Arial Narrow Bold
sbcFont.getName() :Arial Narrow
Phrases added to a PdfPCell; PdfPCell added to PdfPTable and then to the document.
Can any one please throw some light here.I am using java 1.6 and itextpdf-5.3.4
The sample template which i am referring please click
here
The one i am tring to create similar to the template,please click
here
I opened the pdf in Adobe Acrobat Pro.The bold font look like narrow even though the font properties are showing as bold in Adobe Acrobat Pro.But when i opened the pdf in a browser,it looks good.

CoreText equivalent for [NSFont fontWithName]

In our app we are storing fonts for custom objects as strings containing the font name (as retrieved from the font panel) and instantiate fonts using
+ (NSFont *)fontWithName:(NSString *)fontName
Now when loading or importing files we'd like to check whether the font name will actually resolve on the current system.
Due to certain design restrictions we need to perform the check in plain old C/C++, i.e. these days using CoreText.
However, there doesn't seem to exist an equivalent CoreText API call working similarly to fontWithName::
CTFontCreateWithName always returns a font as it uses a fallback strategy
CTFontCopyFullName appears to use different names than wha is accepted/used by NSFont..?
So basically the question is:
How can we use CoreText functionality to check whether a font exists on the current system and the font can be instantiated successfully using [NSFont fontWithName:] later..?
It appears that CTFontCopyPostScriptName() will always return a valid result for any string that is understood by [NSFont fontWithName:] - and vice versa.
At least in my experiments across 10.8 - 10.10 and using valid and made-up font names the results of CTFontCopyPostScriptName() could always be used to verify a font name will be valid for NSFont.
Edit #1
Some experimentation shows that it's a good idea to also add a fallback with CTFontCopyFamilyName() to be on the safe side.

IBM Worklight: Change Text of BusyIndicator

I have created a busy indicator and defined the text of the busy indicator globally as below.
WL.ClientMessages.loading = "Please Wait...";
var busyInd = new WL.BusyIndicator('content');
When busyInd.show() is invoked, the loading icon can be shown successfully with "Please Wait...".
Since my mobile app supports multiple language, I have some functions (e.g. setEnglish(), setFrench()) which specify the translated message for different keys. The key WL.ClientMessages.loading has been added to the functions but the message does not change.
Can the text be changed after the busy indicator object is created?
Thanks.
Environment: Worklight 5.0.6
In 5.0.6 this is the behavior of BusyIndicator by design - it is created with some text and uses it throughout its lifetime.
So - a simple way to bypass the problem would be to create a new object after each setLaunguage().

Custom fonts on iOS app - working in Simulator but not iPad

Encountering a weird problem here. I'm developing a game for my school project (non-commercial), and I'm using a custom font Black Chancery (free under GNU GPL). I followed the instructions from multiple sources, which includes:
Add the font to the project (TTF).
Modify app-Info.plist to add the font to it ("Fonts provided by application").
Using [UIFont fontWithName:#"BlackChancery" size:30] when the font is needed.
I could get the font displayed in the Simulator, however when I load it into my iPad, the default system font is used. I'm pretty sure there isn't a problem with the font itself as it displays in the simulator, and I've used FontForge to open the font without any warnings (following from This Question).
Any help is greatly appreciated. Thanks! :)
I can only guess as you haven't posted the contents of your plist or a directory listing of the bundle, but many cases of "resource works on the simulator but not on the device" are caused by the fact that the OS X filesystem is normally configured to be case-insensitive while the filesystem on the device is case sensitive. For example, if your file is named "BlackChancery.TTF" and your plist refers to it as "BlackChancery.ttf", it will be found on the simulator but not on the device.
I was having problem with font not recognizing, I fixed it by checking the correct name of the font by checking info of the font file by Get Info option. In my case the file name was written xyzfont.ttf but actually it was XyzFont.TTF in the info, i replaced and it worked.
Hope, it helps someone.
Another Way
I have come across one more way of finding the correct name, is by installing the font in the FontBook..
Just open FontBook from Finder and select User now from File->Add Fonts select the font you want to add into your application, after little processing the FontBook will show the Font listed in with the Correct name, use the name in the FontBook ignoring the actual ttf file name you have imported or, added to plist.. It should work..
I had the same problem which was resolved with a slight variation on iphonc's solution. The case sensitivity was directly related to the file extension. The problem was associated with my font file named: Choc.TTF
I had to remove the reference to the file in xCode 4.1
Rename the file to Choc.ttf (note lower case file extension)
Add the reference back into xCode
Perform a clean and re-build for the device
Conclusion (in my particular case):
Case sensitivity applies not JUST to the file name, but to the file extension as well (i.e. iOS device appears to tolerate only lower case).
My answer is different from all the rest. I had a problem because the font was all one word and lowercase "compassnormal.ttf" and the name in the file was Compass. So, my code was:
[UIFont fontWithName:#"Compass" size:24]]
Bundle Resource said:
compassnormal.ttf
~info.plist said:
compassnormal.ttf
None of this worked until I changed the actual filename to match it's official name in fontbook.
deleted all references from Bundle Resources and ~info.plist;
added font with updated name to Bundle Resources;
updated plist with new name;
tested in simulator and on device, Voila!
I have also experienced a problem with fonts containing the dash (-) character. Remove that character from your font names and try with that.
So your font named Gotham-Black.ttf should be named GothamBlack.ttf
Also check that your fonts are not zero bytes. I had this same issue and it turned out that my font files had emptied themselves at some stage. Probably when rearranging them in XCode and AppCode.
You have to use the real font name in the [UIFont fontWithName:#"... method! Not the ttf filename!!!
This real name is mostly far away from the filename. Just open the rtf in the Mac font utility. In the header you see the font family!!! Only the family!!! if you now use
NSArray *fontNames = [UIFont fontNamesForFamilyName:#"MyFontNameFamily"];
NSLog(#"%#", fontNames);
in your code, you get the real real real name in the console ;-)
But in the plist entry you still need the (case sensitive) filename!!!
I have the same issue on Xcode 6. My file name was My Font.ttf, it doesn't work. I manage to make it works when I rename it to My Font.TTF, just change the file extension to uppercase.