weimingtom / canvasplusplus

Automatically exported from code.google.com/p/canvasplusplus
1 stars 0 forks source link

Missing font parser (GDI, D2D etc. will use the same parser) #1

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago

See:
3.7 Shorthand font property: the font property
http://www.w3.org/TR/css3-fonts/#font-prop

The ‘font’ property is, except as described below, a shorthand property for 
setting ‘font-style’, ‘font-variant’, ‘font-weight’, 
‘font-size’, ‘line-height’, ‘font-family’ at the same place in the 
stylesheet.

Samples:

p { font: 12pt/14pt sans-serif }
p { font: 80% sans-serif }
p { font: x-large/110% "new century schoolbook", serif }
p { font: bold italic large Palatino, serif }
p { font: normal small-caps 120%/120% fantasy }
p { font: oblique 12pt "Helvetica Neue", serif; font-stretch: condensed }

We should be abble to write:

context.font = "12pt bold sans-serif";

Original issue reported on code.google.com by thiago.adams on 2 Feb 2012 at 12:51

GoogleCodeExporter commented 9 years ago
See item text of:
http://dev.w3.org/html5/2dcontext/#dom-context-2d-font

Sample:
context.font = 'italic 400 12px/2 Unknown Font, sans-serif';

Original comment by thiago.adams on 2 Feb 2012 at 12:53

GoogleCodeExporter commented 9 years ago

Original comment by thiago.adams on 2 Feb 2012 at 12:58

GoogleCodeExporter commented 9 years ago
Thanks for linking to the specification, I will get right on this.

Original comment by jpn.s...@gmail.com on 2 Feb 2012 at 9:21

GoogleCodeExporter commented 9 years ago
LL1 grammar

module FontShorthand
{
    language FontShorthand
    {
        interleave BLANKS = ' '+;

        token Normal = "normal";
        token Italic = "italic";
        token Oblique = "oblique";
        token Bold = "bold";
        token xxsmall = "xx-small";        
        token xsmall = "x-small";
        token small = "small";
        token medium  = "medium";
        token large = "large";
        token xlarge = "x-large";        
        token xxlarge = "xx-large";

        token larger = "larger";
        token smaller = "smaller";

        token A100 = "100";
        token A200 = "200";
        token A300 = "300";
        token A400 = "400";
        token A500 = "500";
        token A600 = "600";
        token A700 = "700";
        token A800 = "800";
        token A900 = "900";
        token Percent = ('0'..'9')+ "%";
        token Points = ('0'..'9')+ "pt";
        token Pixels = ('0'..'9')+ "px";
        token FontName = ('A'..'Z' | 'a'..'z' | '-' )+;

    syntax Main = FontStyleGroup FontSize FontName {SetFontName};

    syntax FontStyleGroup = FontStyle FontWeight;
    syntax FontStyle = "normal" {SetNormalStyle} | "italic" {SetItalic} | "oblique" {SetOblique} | empty {SetNormalStyle};
    syntax FontWeight = "normal" {SetNormalWeight}
                        | "bold" {SetWeightBold}
                        | "100" {SetWeight100}
                        | "200" {SetWeight200}
                        | "300" {SetWeight300}
                        | "400" {SetWeight400}
                        | "500" {SetWeight500}
                        | "600" {SetWeight600}
                        | "700" {SetWeight700}
                        | "800" {SetWeight800}
                        | "900" {SetWeight900}
                        | empty {SetNormalWeight};

    syntax FontSize = RelativeSize | AbsoluteSize | Percent {SetSizePercent}| Points {SetSizePoints}| Pixels {SetSizePixels};
    syntax RelativeSize = "larger" {SetSizeLarger}| "smaller" {SetSizeSmaller};
    syntax AbsoluteSize = "xx-small" {SetSizexxsmall}| 
                          "x-small" {SetSizexsmall}| 
                          "small" {SetSizesmall}|
                          "medium" {SetSizemedium}| 
                          "large" {SetSizelarge}|
                          "x-large" {SetSizexlarge}|  
                          "xx-large" {SetSizexxlarge};

    }
}

Original comment by thiago.adams on 6 Mar 2012 at 7:57