Skip to content

Commit

Permalink
Merge branch 'master' of github.com:silexlabs/Cocktail
Browse files Browse the repository at this point in the history
  • Loading branch information
yanhick committed May 18, 2013
2 parents bcb4a59 + edc0086 commit 0fcd698
Show file tree
Hide file tree
Showing 7 changed files with 181 additions and 519 deletions.
16 changes: 8 additions & 8 deletions cocktail/core/font/FontData.hx
Expand Up @@ -20,7 +20,7 @@ class FontMetricsVO {
* The font size of
* the htmlElement, in pixels
*/
public var fontSize(default, null):Float;
public var fontSize:Float;

/**
* A characteristic height
Expand All @@ -30,7 +30,7 @@ class FontMetricsVO {
* for the font has a whole,
* not specific to any glyphs
*/
public var ascent(default, null):Float;
public var ascent:Float;

/**
* A characteristic height
Expand All @@ -40,41 +40,41 @@ class FontMetricsVO {
* for the font has a whole,
* not specific to any glyphs
*/
public var descent(default, null):Float;
public var descent:Float;

/**
* This is a standard metrics used
* to define a font size. Represents
* the height of a lowercase "x" glyph
* at the given font size
*/
public var xHeight(default, null):Float;
public var xHeight:Float;

/**
* A suggested offset to apply
* from the baseline for subscript
* glyphs
*/
public var subscriptOffset(default, null):Float;
public var subscriptOffset:Float;

/**
* A suggested offset to apply
* from the baseline for superscript
* glyphs
*/
public var superscriptOffset(default, null):Float;
public var superscriptOffset:Float;

/**
* A suggested offset to apply from
* the baseline when drawing underlines
*/
public var underlineOffset(default, null):Float;
public var underlineOffset:Float;

/**
* the width of a space character for
* a given font at a given size
*/
public var spaceWidth(default, null):Float;
public var spaceWidth:Float;

public function new(fontSize:Float, ascent:Float, descent:Float, xHeight:Float, subscriptOffset:Float, superscriptOffset:Float,
underlineOffset:Float, spaceWidth:Float)
Expand Down
13 changes: 12 additions & 1 deletion cocktail/core/graphics/TextDrawer.hx
Expand Up @@ -83,6 +83,17 @@ class TextDrawer
_destPoint.x = inlineBox.bounds.x + elementRenderer.globalBounds.x - scrollOffset.x;
_destPoint.y = inlineBox.bounds.y + elementRenderer.globalBounds.y - scrollOffset.y;


//TODO IMPORTANT : this is sa big HACK ! the core package should not
//have conditional compilation. This is here to circumvent the lack of
//TextLineMetrics in NME preventing from getting the right ascent and descent.
//This should be removed as soon as swithing to Haxe3 as latest NME release
//(3.5.6) has TextLineMetrics
#if flash
//add the text inline box own leaded ascent and remove the ascent of the text
_destPoint.y += inlineBox.leadedAscent - elementRenderer.coreStyle.fontMetrics.ascent;
#end

//TODO 2 : should not happen, seems to happen for spaces
//on empty lines
if (inlineBox.lineBox != null)
Expand Down Expand Up @@ -130,7 +141,7 @@ class TextDrawer
_decorationRect.width = _renderRect.width;
_decorationRect.height = TEXT_DECORATION_THICKNESS;
_decorationRect.x = _destPoint.x;
_decorationRect.y = _destPoint.y + elementRenderer.getLeadedAscent() - elementRenderer.getLeadedDescent();
_decorationRect.y = _destPoint.y + elementRenderer.coreStyle.fontMetrics.ascent / 2;

graphicsContext.nativeLayer.graphics.fillRect(_decorationRect, elementRenderer.coreStyle.usedValues.color, clipRect);
}
Expand Down
3 changes: 1 addition & 2 deletions cocktail/port/Bindings.hx
Expand Up @@ -38,16 +38,15 @@ typedef Platform = cocktail.port.platform.flash_player.Platform;
typedef NativeTextInput = cocktail.port.platform.flash_player.NativeTextInput;
typedef NativeTextArea = cocktail.port.platform.flash_player.NativeTextArea;
typedef NativePasswordInput = cocktail.port.platform.flash_player.NativePasswordInput;
typedef FontBuilder = cocktail.port.platform.flash_player.FontBuilder;

//bindings for flash (or air), compiled either using nme or without
#if flash
typedef NativeVideo = cocktail.port.platform.flash_player.NativeVideo;
typedef FontBuilder = cocktail.port.platform.flash_player.FontBuilder;

//bindings for nme when not building for flash or air
#elseif nme
typedef NativeVideo = cocktail.port.base.NativeMedia;
typedef FontBuilder = cocktail.port.platform.nme.FontBuilder;
#end

#end
Expand Down
92 changes: 0 additions & 92 deletions cocktail/port/platform/flash_player/FlashFontBuilderBase.hx

This file was deleted.

0 comments on commit 0fcd698

Please sign in to comment.