I develop my app with AIR, Starling and FeatherUI for iOS.
I use Label with TextBlockTextRenderer (flash.text.engine.TextBlock).
I faced the following problem: http://monosnap.com/image/1chKMEoG2fDufCMJIdrgcX3dcTbLMa
In short: Some parts of letters are being cut. (this issue affect languages that has high glyphs, like Norway, German, Arabic etc...)
I already did ask the question about possible fix for this issue: http://forum.starling-framework.org/topic/why-does-label-cuts-letters but suggested workarounds are only good for certain cases. They do not solve the whole problem.
What I know so far:
baselineZero property doesn't work for me. See description here: http://forum.starling-framework.org/topic/why-does-label-cuts-letters#post-61471
Settings baselineFontDescription works but cannot be used as proper workaround - you have to manually measure baselineFontSize all the time. See description here: http://forum.starling-framework.org/topic/why-does-label-cuts-letters#post-61471
Any ideas how to fix this issue?
The workaround i am currently using is to add transparent shadow filter.
You may ned to increase radius depending on your font.
This is by no means a good solution, just a dirty temporary fix.
public static function defaultTextRendererFactory():ITextRenderer
{
// Transparent shadow helps to avoid clipping on some fonts
var clipFix:DropShadowFilter = new DropShadowFilter(0.0, 0.0, 0x000000, 0.0, 2.0, 2.0, 0.0);
var textRenderer:TextBlockTextRenderer = new TextBlockTextRenderer();
textRenderer.nativeFilters = [clipFix];
return textRenderer;
}
Related
I'm creating a Swift (SpriteKit) game where I have my score. I'm using BMGlyph Library and Software to add a custom font/label to my game.
Here's how i create the entire bmglyph label & font:
let bestScoreFont = BMGlyphFont(name: "scorefont_small_gold")
self.bestScoreLabel = BMGlyphLabel.init(text: "best 0", font: bestScoreFont)
self.bestScoreLabel.zPosition = ZIndexPosition.HUD
self.bestScoreLabel.position = CGPoint(x: 70, y: self.FRAME_HEIGHT - 20)
self.bestScoreLabel.textJustify = BMGlyphJustifyLeft
Now, this label as you may see, it's being placed on the left-upper corner.
The problem is, that if the player does a huge score or whatever the score is, the label moves to the left as the text grows instead of remaining aligned left and growing right. I don't know if I'm explaining myself correctly.
Tested with different values on the score, and the longer it gets, the deeper it goes through the left side of the screen.
For instance, i tested adding a huge value like 123123123123123. This is how it looks:
Horrible, right? haha.
Anyways, does anyone know how to solve this? and make it stick in the same place left-aligned?
Thanks in advance.
Okay, looks like I found a way to do it with BMGlyph. Although there's a registered issue as #Alessandro Ornano told me.
There are 2 attributes to set alignment in BMGlyph.
1) textJustify
2) horizontalAlignment & verticalAlignment
The one it works is the 2nd. And by placing BMGlyphHorizontalAlignmentLeft as a value. Tested BMGlyphHorizontalAlignmentRight and works as well.
I've been trying to create my app and something is bugging me very much,
I have images of what I am trying to achieve:
1)
2 )
number 1 shows what I am trying to do, the letters are "squeezed" together making the text appear tighter with a short width even though the letter sizing is big.
number 2 shows my attempt to achieve this, I tried multiple different ways to get that same look but failed for hours, does anyone have any suggestions or know how to make the text look like that in the first picture?
I appreciate any help, thank you!
The only way how to do it AFAIK is to use transform on UILabel, like this:
let widthTransform = 0.8 // Shrink label to 80% of its width
label.layer.transform = CATransform3DMakeScale(widthTransform, 1.0, 1.0);
Hope it helps!
Note* that transform work for about 30% of decrease (even less imo), then it just starts to look very bad. You can also change text spacing, but if you calculate it dynamically, you could end up with negative one and that looks terrible. The easiest way really is then just change of the design :)
Options:
You can decrease character spacing like in this answer
and increase font size.
Having fun with transformation on layer is really awful idea, as later you won't be able to get the height of text etc -> just everything will be working wrong.
You can also just use different font.
I'm using border-radius:50%;
This doesn't work in IOS4?
but http://caniuse.com/#search=border-radius says it does?
Huh? Whats going on?
In IOS4,
It appears that it doesn't support border-radius:50%?
Therefore had to come up with some JS to work out the percentage in Pixels.
Something Like:
var radius = circleWidth / 2;
$jq('.circle').css('border-radius', radius + "px")
Doesn't appear to be documented anywhere either.
According to css3.info: percentages refer to the corresponding dimensions of the border box.
Does you box have a defined height/width?
Does it work on other mobile browsers?
Maybe you need to add the -webkit- prefix to it.
I am using flot with the plugin "jquery.flot.axislabels.js", but I can't find other documentation than the README file.
So the general question is "where can I find some complete documentation ?"
And the more specific one is: "How to set the label's color ?"
Some properties are available, such as "axisLabelFontSizePixels", "axisLabelFontFamily", etc... so I've tried "axisLabelColor" and "axisLabelFontColor" without any result.
I tried to use CSS too, according to this: http://people.mozilla.com/~mcote/flot-axislabels/example/
But it does not work either. Maybe CSS is working with an older version of axislabel.js.
Ideally I'd avoid doing this with CSS, I guess that if we are able to choose the font we are able to choose the color. But I cant find what syntax I have to use...
If someone knows something, I'd be glad to read it :-)
Thanks and regards,
S.
From looking at the source code it doesn't look like the plugin provides that option in either of it's two modes of operation:
1.) Draw the labels using the canvas - no ability to set color (only font family and size). If you are handy with JavaScript adding color wouldn't be too difficult. (You are probably using this option since it explains why your CSS doesn't work.)
2.) Draw the labels using HTML DIVs. This is what your linked example does. In it the author specifies the color through an inline CSS tag. How I would do it though to keep it all together is after your plot call:
$('.yaxisLabel').css('color','red');
$('.y2axisLabel').css('color','orange');
$('.y3axisLabel').css('color','green');
$('.y4axisLabel').css('color','purple');
Example here.
I found it simpler to just add !important targeting the classes generated by flot. For targeting axis, you can aim for .yaxisLabel or .xaxisLabel, or for the whole thing target .flot-text.
.flot-text {
color: rgba(255, 255, 255, 0.3) !important
}
I know this question has one accepted answer, but just thought of sharing how I eventually got it working.
FLot version: Flot 0.8.3
I had to explicitly set axisLabelUseCanvas:false and then write a bit of jQuery code:
$('.flot-tick-label').css('color','red');
And there we go, after couple of hours of frustration, it was finally red!
Hope this helps someone who is lost in Flot.
I had to set axisLabelUseCanvas:false explicitly and use $('.axisLabels').css('color','red'); to make them red
I'm drawing some text in Mac/iOS cross-platform code using CoreText. I may be using fonts that do not have a real "Italic" version installed in the OS for all users, but they need to be aware that the text is italic even then.
With AppKit's NSAttributedString -drawAtPoint:, I can use NSObliquenessAttributeName to make the text slanted (and thus look italic -- well, oblique). CoreText doesn't seem to have an equivalent for this attribute. At least I found none in CTStringAttributes.h (not that there's any documentation even years after CoreText was released).
Does anyone know how I can get oblique text with CoreText on iOS?
I’d try using the affine transform argument to CTFontCreateWithName() with a shear matrix. For instance
CGAffineTransform matrix = { 1, 0, 0.5, 1, 0, 0 };
CTFontRef myFont = CTFontCreateWithName(CFSTR("Helvetica"), 48, &matrix);
That will create quite an extreme skew (assuming I got it right), but you get the idea.
Update:
In fact, the documentation appears to imply that this is the right way to do things.
Displaying a font that has no italic trait as italic is generally a bad idea. However, I can understand that there are some cases where this has to be enforced anyways.
The only solution that comes to my mind right now is to create a custom font with a sheared font matrix:
CGAffineTransform matrix = CGAffineTransformMake(1, tan(degreesToRadians(0)), tan(degreesToRadians(20)), 1, 0, 0);
CTFontRef myfont = CTFontCreateWithName(CFSTR("Helvetica"), 48, &matrix);
You'll have to play with the matrix and see what brings the best results. (Please not that this is a fake code mix out of my head and the internet.)
Haven't tried, but according to iOS Programming Pushing The Limits, passing kCTFontItalicTrait to CTFontCreateCopyWithSymbolicTraits will choose true italic if available, and oblique otherwise. There's also kCTFontSlantTrait for manual decimal slant up to 30 degrees.