Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
Developer Community or GitHub with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
Created attachment 14593 [details]
Hey folks, I think we an issue with CTFont.WithSymbolicTraits()
Consider the following code:
var basefont = new CTFont("CourierPrime", 14);
var boldFont = basefont.WithSymbolicTraits (basefont.Size, CTFontSymbolicTraits.Bold, basefont.SymbolicTraits);
var italicFont = basefont.WithSymbolicTraits (basefont.Size, CTFontSymbolicTraits.Italic, CTFontSymbolicTraits.Italic);
var boldItalicFont = basefont.WithSymbolicTraits (basefont.Size, CTFontSymbolicTraits.Bold | CTFontSymbolicTraits.Italic, CTFontSymbolicTraits.Bold | CTFontSymbolicTraits.Italic);
CTFont.WithSymbolicTraits has a couple of interesting arguments:
Symbolic Trait Value (`symTraitValue`), and Symbolic Trait Mask (`symTraitMask`)
one of them (the value) tells the system what traits you want to add to the new font, and the other (the mask) tells it what traits to copy over to the new font.
if you manually specify which symbolic traits you want to mask (as seen in the italicFont and boldItalicFont ctors above), it works just fine. However, if you pass in the symbolic traits directly from the SymbolicTraits property (as seen in the `boldFont` ctor above), it'll always return null where there should be a CTFont.
to further complicate matters, if i were to do the following:
var boldFont = basefont.WithSymbolicTraits (basefont.Size, CTFontSymbolicTraits.Bold, CTFontSymbolicTraits.Mask);
var boldFont = basefont.WithSymbolicTraits (basefont.Size, CTFontSymbolicTraits.Bold, CTFontSymbolicTraits.None);
I would expect to get a bold font, but instead, I get a non-bolded font.
whereas this, gets me the font i want:
var boldFont = basefont.WithSymbolicTraits (basefont.Size, CTFontSymbolicTraits.Bold,CTFontSymbolicTraits.Bold);
I've attached a very simple repro with this code.
Version: 220.127.116.11 (Business Edition)
Build date: 2015-12-08 16:20:29-0500
The bindings are a very straight, thin layer above the CoreText API `CTFontCreateCopyWithSymbolicTraits`.
We'll double check this but it's very possible the same behaviour exists on ObjC.
Created attachment 15496 [details]
Xamarin iOS Smaller Test Case
Created a smaller test case so we can have a line by line port to ObjC
Created attachment 15497 [details]
Xcode ObjC test case
Objective C line by line port of Xamarin iOS Smaller test case
As Sebastien mentioned in comment #1 we have a thin layer above the CoreText API, I created a smaller test case for X.I so we could have a line by line port to ObjC. I get the same results in the ObjC app with the code provided in repro solution by Bryan.
So this seems to be the underlying CoreText API not working as we expect :/ (fortunately not a binding issue)