Calculate font metrics from the system

This commit is contained in:
Sam Harwell 2013-01-10 13:41:25 -06:00
parent 723637fc59
commit f19059d6b5
7 changed files with 40 additions and 930 deletions

View File

@ -1,228 +0,0 @@
/*
* [The "BSD license"]
* Copyright (c) 2012 Terence Parr
* Copyright (c) 2012 Sam Harwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.antlr.v4.runtime.tree.gui;
public class ArialBlack extends BasicFontMetrics {
{
maxCharHeight = 905;
widths[32] = 333; // space
widths[33] = 333; // exclam
widths[34] = 500; // quotedbl
widths[35] = 660; // numbersign
widths[36] = 666; // dollar
widths[37] = 1000; // percent
widths[38] = 889; // ampersand
widths[39] = 277; // quotesingle
widths[40] = 389; // parenleft
widths[41] = 389; // parenright
widths[42] = 556; // asterisk
widths[43] = 660; // plus
widths[44] = 333; // comma
widths[45] = 333; // hyphen
widths[46] = 333; // period
widths[47] = 277; // slash
widths[48] = 666; // zero
widths[49] = 666; // one
widths[50] = 666; // two
widths[51] = 666; // three
widths[52] = 666; // four
widths[53] = 666; // five
widths[54] = 666; // six
widths[55] = 666; // seven
widths[56] = 666; // eight
widths[57] = 666; // nine
widths[58] = 333; // colon
widths[59] = 333; // semicolon
widths[60] = 660; // less
widths[61] = 660; // equal
widths[62] = 660; // greater
widths[63] = 610; // question
widths[64] = 740; // at
widths[65] = 777; // A
widths[66] = 777; // B
widths[67] = 777; // C
widths[68] = 777; // D
widths[69] = 722; // E
widths[70] = 666; // F
widths[71] = 833; // G
widths[72] = 833; // H
widths[73] = 389; // I
widths[74] = 666; // J
widths[75] = 833; // K
widths[76] = 666; // L
widths[77] = 943; // M
widths[78] = 833; // N
widths[79] = 833; // O
widths[80] = 722; // P
widths[81] = 833; // Q
widths[82] = 777; // R
widths[83] = 722; // S
widths[84] = 722; // T
widths[85] = 833; // U
widths[86] = 777; // V
widths[87] = 1000; // W
widths[88] = 777; // X
widths[89] = 777; // Y
widths[90] = 722; // Z
widths[91] = 389; // bracketleft
widths[92] = 277; // backslash
widths[93] = 389; // bracketright
widths[94] = 660; // asciicircum
widths[95] = 500; // underscore
widths[96] = 333; // grave
widths[97] = 666; // a
widths[98] = 666; // b
widths[99] = 666; // c
widths[100] = 666; // d
widths[101] = 666; // e
widths[102] = 389; // f
widths[103] = 666; // g
widths[104] = 666; // h
widths[105] = 333; // i
widths[106] = 333; // j
widths[107] = 666; // k
widths[108] = 333; // l
widths[109] = 1000; // m
widths[110] = 666; // n
widths[111] = 666; // o
widths[112] = 666; // p
widths[113] = 666; // q
widths[114] = 443; // r
widths[115] = 610; // s
widths[116] = 443; // t
widths[117] = 666; // u
widths[118] = 610; // v
widths[119] = 943; // w
widths[120] = 666; // x
widths[121] = 610; // y
widths[122] = 556; // z
widths[123] = 389; // braceleft
widths[124] = 277; // bar
widths[125] = 389; // braceright
widths[126] = 660; // asciitilde
widths[160] = 333; // nbspace
widths[161] = 333; // exclamdown
widths[162] = 666; // cent
widths[163] = 666; // sterling
widths[164] = 660; // currency
widths[165] = 666; // yen
widths[166] = 277; // brokenbar
widths[167] = 666; // section
widths[168] = 333; // dieresis
widths[169] = 799; // copyright
widths[170] = 399; // ordfeminine
widths[171] = 666; // guillemotleft
widths[172] = 660; // logicalnot
widths[173] = 333; // sfthyphen
widths[174] = 799; // registered
widths[175] = 500; // overscore
widths[176] = 399; // degree
widths[177] = 660; // plusminus
widths[178] = 399; // twosuperior
widths[179] = 399; // threesuperior
widths[180] = 333; // acute
widths[181] = 666; // mu1
widths[182] = 850; // paragraph
widths[183] = 333; // middot
widths[184] = 333; // cedilla
widths[185] = 399; // onesuperior
widths[186] = 399; // ordmasculine
widths[187] = 666; // guillemotright
widths[188] = 1000; // onequarter
widths[189] = 1000; // onehalf
widths[190] = 1000; // threequarters
widths[191] = 610; // questiondown
widths[192] = 777; // Agrave
widths[193] = 777; // Aacute
widths[194] = 777; // Acircumflex
widths[195] = 777; // Atilde
widths[196] = 777; // Adieresis
widths[197] = 777; // Aring
widths[198] = 1000; // AE
widths[199] = 777; // Ccedilla
widths[200] = 722; // Egrave
widths[201] = 722; // Eacute
widths[202] = 722; // Ecircumflex
widths[203] = 722; // Edieresis
widths[204] = 389; // Igrave
widths[205] = 389; // Iacute
widths[206] = 389; // Icircumflex
widths[207] = 389; // Idieresis
widths[208] = 777; // Eth
widths[209] = 833; // Ntilde
widths[210] = 833; // Ograve
widths[211] = 833; // Oacute
widths[212] = 833; // Ocircumflex
widths[213] = 833; // Otilde
widths[214] = 833; // Odieresis
widths[215] = 660; // multiply
widths[216] = 833; // Oslash
widths[217] = 833; // Ugrave
widths[218] = 833; // Uacute
widths[219] = 833; // Ucircumflex
widths[220] = 833; // Udieresis
widths[221] = 777; // Yacute
widths[222] = 722; // Thorn
widths[223] = 666; // germandbls
widths[224] = 666; // agrave
widths[225] = 666; // aacute
widths[226] = 666; // acircumflex
widths[227] = 666; // atilde
widths[228] = 666; // adieresis
widths[229] = 666; // aring
widths[230] = 1000; // ae
widths[231] = 666; // ccedilla
widths[232] = 666; // egrave
widths[233] = 666; // eacute
widths[234] = 666; // ecircumflex
widths[235] = 666; // edieresis
widths[236] = 333; // igrave
widths[237] = 333; // iacute
widths[238] = 333; // icircumflex
widths[239] = 333; // idieresis
widths[240] = 666; // eth
widths[241] = 666; // ntilde
widths[242] = 666; // ograve
widths[243] = 666; // oacute
widths[244] = 666; // ocircumflex
widths[245] = 666; // otilde
widths[246] = 666; // odieresis
widths[247] = 660; // divide
widths[248] = 666; // oslash
widths[249] = 666; // ugrave
widths[250] = 666; // uacute
widths[251] = 666; // ucircumflex
widths[252] = 666; // udieresis
widths[253] = 610; // yacute
widths[254] = 666; // thorn
widths[255] = 610; // ydieresis
}
}

View File

@ -1,228 +0,0 @@
/*
* [The "BSD license"]
* Copyright (c) 2012 Terence Parr
* Copyright (c) 2012 Sam Harwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.antlr.v4.runtime.tree.gui;
public class ArialNarrow extends BasicFontMetrics {
{
maxCharHeight = 921;
widths[32] = 228; // space
widths[33] = 228; // exclam
widths[34] = 291; // quotedbl
widths[35] = 456; // numbersign
widths[36] = 456; // dollar
widths[37] = 729; // percent
widths[38] = 546; // ampersand
widths[39] = 157; // quotesingle
widths[40] = 272; // parenleft
widths[41] = 272; // parenright
widths[42] = 318; // asterisk
widths[43] = 479; // plus
widths[44] = 228; // comma
widths[45] = 272; // hyphen
widths[46] = 228; // period
widths[47] = 228; // slash
widths[48] = 456; // zero
widths[49] = 456; // one
widths[50] = 456; // two
widths[51] = 456; // three
widths[52] = 456; // four
widths[53] = 456; // five
widths[54] = 456; // six
widths[55] = 456; // seven
widths[56] = 456; // eight
widths[57] = 456; // nine
widths[58] = 228; // colon
widths[59] = 228; // semicolon
widths[60] = 479; // less
widths[61] = 479; // equal
widths[62] = 479; // greater
widths[63] = 456; // question
widths[64] = 832; // at
widths[65] = 546; // A
widths[66] = 546; // B
widths[67] = 591; // C
widths[68] = 591; // D
widths[69] = 546; // E
widths[70] = 500; // F
widths[71] = 638; // G
widths[72] = 591; // H
widths[73] = 228; // I
widths[74] = 410; // J
widths[75] = 546; // K
widths[76] = 456; // L
widths[77] = 683; // M
widths[78] = 591; // N
widths[79] = 638; // O
widths[80] = 546; // P
widths[81] = 638; // Q
widths[82] = 591; // R
widths[83] = 546; // S
widths[84] = 500; // T
widths[85] = 591; // U
widths[86] = 546; // V
widths[87] = 773; // W
widths[88] = 546; // X
widths[89] = 546; // Y
widths[90] = 500; // Z
widths[91] = 228; // bracketleft
widths[92] = 228; // backslash
widths[93] = 228; // bracketright
widths[94] = 384; // asciicircum
widths[95] = 456; // underscore
widths[96] = 272; // grave
widths[97] = 456; // a
widths[98] = 456; // b
widths[99] = 410; // c
widths[100] = 456; // d
widths[101] = 456; // e
widths[102] = 228; // f
widths[103] = 456; // g
widths[104] = 456; // h
widths[105] = 182; // i
widths[106] = 182; // j
widths[107] = 410; // k
widths[108] = 182; // l
widths[109] = 683; // m
widths[110] = 456; // n
widths[111] = 456; // o
widths[112] = 456; // p
widths[113] = 456; // q
widths[114] = 272; // r
widths[115] = 410; // s
widths[116] = 228; // t
widths[117] = 456; // u
widths[118] = 410; // v
widths[119] = 591; // w
widths[120] = 410; // x
widths[121] = 410; // y
widths[122] = 410; // z
widths[123] = 273; // braceleft
widths[124] = 212; // bar
widths[125] = 273; // braceright
widths[126] = 479; // asciitilde
widths[160] = 228; // nbspace
widths[161] = 272; // exclamdown
widths[162] = 456; // cent
widths[163] = 456; // sterling
widths[164] = 456; // currency
widths[165] = 456; // yen
widths[166] = 212; // brokenbar
widths[167] = 456; // section
widths[168] = 272; // dieresis
widths[169] = 604; // copyright
widths[170] = 303; // ordfeminine
widths[171] = 456; // guillemotleft
widths[172] = 479; // logicalnot
widths[173] = 272; // sfthyphen
widths[174] = 604; // registered
widths[175] = 500; // overscore
widths[176] = 399; // degree
widths[177] = 548; // plusminus
widths[178] = 272; // twosuperior
widths[179] = 272; // threesuperior
widths[180] = 272; // acute
widths[181] = 576; // mu1
widths[182] = 439; // paragraph
widths[183] = 271; // middot
widths[184] = 272; // cedilla
widths[185] = 272; // onesuperior
widths[186] = 298; // ordmasculine
widths[187] = 456; // guillemotright
widths[188] = 684; // onequarter
widths[189] = 684; // onehalf
widths[190] = 684; // threequarters
widths[191] = 500; // questiondown
widths[192] = 546; // Agrave
widths[193] = 546; // Aacute
widths[194] = 546; // Acircumflex
widths[195] = 546; // Atilde
widths[196] = 546; // Adieresis
widths[197] = 546; // Aring
widths[198] = 819; // AE
widths[199] = 591; // Ccedilla
widths[200] = 546; // Egrave
widths[201] = 546; // Eacute
widths[202] = 546; // Ecircumflex
widths[203] = 546; // Edieresis
widths[204] = 228; // Igrave
widths[205] = 228; // Iacute
widths[206] = 228; // Icircumflex
widths[207] = 228; // Idieresis
widths[208] = 591; // Eth
widths[209] = 591; // Ntilde
widths[210] = 638; // Ograve
widths[211] = 638; // Oacute
widths[212] = 638; // Ocircumflex
widths[213] = 638; // Otilde
widths[214] = 638; // Odieresis
widths[215] = 479; // multiply
widths[216] = 638; // Oslash
widths[217] = 591; // Ugrave
widths[218] = 591; // Uacute
widths[219] = 591; // Ucircumflex
widths[220] = 591; // Udieresis
widths[221] = 546; // Yacute
widths[222] = 546; // Thorn
widths[223] = 500; // germandbls
widths[224] = 456; // agrave
widths[225] = 456; // aacute
widths[226] = 456; // acircumflex
widths[227] = 456; // atilde
widths[228] = 456; // adieresis
widths[229] = 456; // aring
widths[230] = 729; // ae
widths[231] = 410; // ccedilla
widths[232] = 456; // egrave
widths[233] = 456; // eacute
widths[234] = 456; // ecircumflex
widths[235] = 456; // edieresis
widths[236] = 228; // igrave
widths[237] = 228; // iacute
widths[238] = 228; // icircumflex
widths[239] = 228; // idieresis
widths[240] = 456; // eth
widths[241] = 456; // ntilde
widths[242] = 456; // ograve
widths[243] = 456; // oacute
widths[244] = 456; // ocircumflex
widths[245] = 456; // otilde
widths[246] = 456; // odieresis
widths[247] = 548; // divide
widths[248] = 500; // oslash
widths[249] = 456; // ugrave
widths[250] = 456; // uacute
widths[251] = 456; // ucircumflex
widths[252] = 456; // udieresis
widths[253] = 410; // yacute
widths[254] = 456; // thorn
widths[255] = 410; // ydieresis
}
}

View File

@ -1,229 +0,0 @@
/*
* [The "BSD license"]
* Copyright (c) 2012 Terence Parr
* Copyright (c) 2012 Sam Harwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.antlr.v4.runtime.tree.gui;
// actually from Arial but seems to work
public class Helvetica extends BasicFontMetrics {
{
maxCharHeight = 896;
widths[32] = 277; // space
widths[33] = 277; // exclam
widths[34] = 354; // quotedbl
widths[35] = 556; // numbersign
widths[36] = 556; // dollar
widths[37] = 889; // percent
widths[38] = 666; // ampersand
widths[39] = 190; // quotesingle
widths[40] = 333; // parenleft
widths[41] = 333; // parenright
widths[42] = 389; // asterisk
widths[43] = 583; // plus
widths[44] = 277; // comma
widths[45] = 333; // hyphen
widths[46] = 277; // period
widths[47] = 277; // slash
widths[48] = 556; // zero
widths[49] = 556; // one
widths[50] = 556; // two
widths[51] = 556; // three
widths[52] = 556; // four
widths[53] = 556; // five
widths[54] = 556; // six
widths[55] = 556; // seven
widths[56] = 556; // eight
widths[57] = 556; // nine
widths[58] = 277; // colon
widths[59] = 277; // semicolon
widths[60] = 583; // less
widths[61] = 583; // equal
widths[62] = 583; // greater
widths[63] = 556; // question
widths[64] = 1015; // at
widths[65] = 666; // A
widths[66] = 666; // B
widths[67] = 722; // C
widths[68] = 722; // D
widths[69] = 666; // E
widths[70] = 610; // F
widths[71] = 777; // G
widths[72] = 722; // H
widths[73] = 277; // I
widths[74] = 500; // J
widths[75] = 666; // K
widths[76] = 556; // L
widths[77] = 833; // M
widths[78] = 722; // N
widths[79] = 777; // O
widths[80] = 666; // P
widths[81] = 777; // Q
widths[82] = 722; // R
widths[83] = 666; // S
widths[84] = 610; // T
widths[85] = 722; // U
widths[86] = 666; // V
widths[87] = 943; // W
widths[88] = 666; // X
widths[89] = 666; // Y
widths[90] = 610; // Z
widths[91] = 277; // bracketleft
widths[92] = 277; // backslash
widths[93] = 277; // bracketright
widths[94] = 469; // asciicircum
widths[95] = 556; // underscore
widths[96] = 333; // grave
widths[97] = 556; // a
widths[98] = 556; // b
widths[99] = 500; // c
widths[100] = 556; // d
widths[101] = 556; // e
widths[102] = 277; // f
widths[103] = 556; // g
widths[104] = 556; // h
widths[105] = 222; // i
widths[106] = 222; // j
widths[107] = 500; // k
widths[108] = 222; // l
widths[109] = 833; // m
widths[110] = 556; // n
widths[111] = 556; // o
widths[112] = 556; // p
widths[113] = 556; // q
widths[114] = 333; // r
widths[115] = 500; // s
widths[116] = 277; // t
widths[117] = 556; // u
widths[118] = 500; // v
widths[119] = 722; // w
widths[120] = 500; // x
widths[121] = 500; // y
widths[122] = 500; // z
widths[123] = 333; // braceleft
widths[124] = 259; // bar
widths[125] = 333; // braceright
widths[126] = 583; // asciitilde
widths[160] = 277; // nbspace
widths[161] = 333; // exclamdown
widths[162] = 556; // cent
widths[163] = 556; // sterling
widths[164] = 556; // currency
widths[165] = 556; // yen
widths[166] = 259; // brokenbar
widths[167] = 556; // section
widths[168] = 333; // dieresis
widths[169] = 736; // copyright
widths[170] = 370; // ordfeminine
widths[171] = 556; // guillemotleft
widths[172] = 583; // logicalnot
widths[173] = 333; // sfthyphen
widths[174] = 736; // registered
widths[175] = 552; // overscore
widths[176] = 399; // degree
widths[177] = 548; // plusminus
widths[178] = 333; // twosuperior
widths[179] = 333; // threesuperior
widths[180] = 333; // acute
widths[181] = 576; // mu1
widths[182] = 537; // paragraph
widths[183] = 333; // middot
widths[184] = 333; // cedilla
widths[185] = 333; // onesuperior
widths[186] = 365; // ordmasculine
widths[187] = 556; // guillemotright
widths[188] = 833; // onequarter
widths[189] = 833; // onehalf
widths[190] = 833; // threequarters
widths[191] = 610; // questiondown
widths[192] = 666; // Agrave
widths[193] = 666; // Aacute
widths[194] = 666; // Acircumflex
widths[195] = 666; // Atilde
widths[196] = 666; // Adieresis
widths[197] = 666; // Aring
widths[198] = 1000; // AE
widths[199] = 722; // Ccedilla
widths[200] = 666; // Egrave
widths[201] = 666; // Eacute
widths[202] = 666; // Ecircumflex
widths[203] = 666; // Edieresis
widths[204] = 277; // Igrave
widths[205] = 277; // Iacute
widths[206] = 277; // Icircumflex
widths[207] = 277; // Idieresis
widths[208] = 722; // Eth
widths[209] = 722; // Ntilde
widths[210] = 777; // Ograve
widths[211] = 777; // Oacute
widths[212] = 777; // Ocircumflex
widths[213] = 777; // Otilde
widths[214] = 777; // Odieresis
widths[215] = 583; // multiply
widths[216] = 777; // Oslash
widths[217] = 722; // Ugrave
widths[218] = 722; // Uacute
widths[219] = 722; // Ucircumflex
widths[220] = 722; // Udieresis
widths[221] = 666; // Yacute
widths[222] = 666; // Thorn
widths[223] = 610; // germandbls
widths[224] = 556; // agrave
widths[225] = 556; // aacute
widths[226] = 556; // acircumflex
widths[227] = 556; // atilde
widths[228] = 556; // adieresis
widths[229] = 556; // aring
widths[230] = 889; // ae
widths[231] = 500; // ccedilla
widths[232] = 556; // egrave
widths[233] = 556; // eacute
widths[234] = 556; // ecircumflex
widths[235] = 556; // edieresis
widths[236] = 277; // igrave
widths[237] = 277; // iacute
widths[238] = 277; // icircumflex
widths[239] = 277; // idieresis
widths[240] = 556; // eth
widths[241] = 556; // ntilde
widths[242] = 556; // ograve
widths[243] = 556; // oacute
widths[244] = 556; // ocircumflex
widths[245] = 556; // otilde
widths[246] = 556; // odieresis
widths[247] = 548; // divide
widths[248] = 610; // oslash
widths[249] = 556; // ugrave
widths[250] = 556; // uacute
widths[251] = 556; // ucircumflex
widths[252] = 556; // udieresis
widths[253] = 500; // yacute
widths[254] = 556; // thorn
widths[255] = 500; // ydieresis
}
}

View File

@ -31,10 +31,12 @@
package org.antlr.v4.runtime.tree.gui;
public class PostScriptDocument {
public static final String DEFAULT_FONT = "Courier New";
protected int boundingBoxWidth;
protected int boundingBoxHeight;
protected BasicFontMetrics fontMetrics;
protected SystemFontMetrics fontMetrics;
protected String fontName;
protected int fontSize = 12;
protected double lineWidth = 0.3;
@ -44,7 +46,7 @@ public class PostScriptDocument {
protected boolean closed = false;
public PostScriptDocument() {
this("CourierNew", 12);
this(DEFAULT_FONT, 12);
}
public PostScriptDocument(String fontName, int fontSize) {
@ -96,23 +98,17 @@ public class PostScriptDocument {
" fill\n" +
" grestore\n" +
" end\n" +
"} def");
"} def\n");
return b;
}
// Courier, Helvetica, Times, ... should be available
public void setFont(String fontName, int fontSize) {
this.fontName = fontName;
this.fontMetrics = new SystemFontMetrics(fontName);
this.fontName = fontMetrics.getFont().getPSName();
this.fontSize = fontSize;
try {
Class<?> c = Class.forName("org.antlr.v4.runtime.tree.gui." + fontName);
this.fontMetrics = (BasicFontMetrics)c.newInstance();
}
catch (Exception e) {
throw new UnsupportedOperationException("No font metrics for "+fontName);
}
ps.append(String.format("/%s findfont\n%d scalefont setfont\n", fontName, fontSize));
ps.append(String.format("/%s findfont %d scalefont setfont\n", this.fontName, fontSize));
}
public void lineWidth(double w) {

View File

@ -30,9 +30,36 @@
package org.antlr.v4.runtime.tree.gui;
public class CourierNew extends BasicFontMetrics {
{
maxCharHeight = 678;
for (int i=0; i<MAX_CHAR; i++) widths[i] = 600;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.GraphicsEnvironment;
import java.awt.font.FontRenderContext;
import java.awt.font.TextLayout;
import java.awt.image.BufferedImage;
/**
*
* @author Sam Harwell
*/
public class SystemFontMetrics extends BasicFontMetrics {
protected final Font font;
public SystemFontMetrics(String fontName) {
BufferedImage img = new BufferedImage(40, 40, BufferedImage.TYPE_4BYTE_ABGR);
Graphics2D graphics = GraphicsEnvironment.getLocalGraphicsEnvironment().createGraphics(img);
FontRenderContext fontRenderContext = graphics.getFontRenderContext();
this.font = new Font(fontName, Font.PLAIN, 1000);
double maxHeight = 0;
for (int i = 0; i < 255; i++) {
TextLayout layout = new TextLayout(Character.toString((char)i), font, fontRenderContext);
maxHeight = Math.max(maxHeight, layout.getBounds().getHeight());
super.widths[i] = (int)layout.getAdvance();
}
super.maxCharHeight = (int)Math.round(maxHeight);
}
public Font getFont() {
return font;
}
}

View File

@ -1,228 +0,0 @@
/*
* [The "BSD license"]
* Copyright (c) 2012 Terence Parr
* Copyright (c) 2012 Sam Harwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.antlr.v4.runtime.tree.gui;
public class TimesNewRoman extends BasicFontMetrics {
{
maxCharHeight = 877;
widths[32] = 250; // space
widths[33] = 333; // exclam
widths[34] = 408; // quotedbl
widths[35] = 500; // numbersign
widths[36] = 500; // dollar
widths[37] = 833; // percent
widths[38] = 777; // ampersand
widths[39] = 180; // quotesingle
widths[40] = 333; // parenleft
widths[41] = 333; // parenright
widths[42] = 500; // asterisk
widths[43] = 563; // plus
widths[44] = 250; // comma
widths[45] = 333; // hyphen
widths[46] = 250; // period
widths[47] = 277; // slash
widths[48] = 500; // zero
widths[49] = 500; // one
widths[50] = 500; // two
widths[51] = 500; // three
widths[52] = 500; // four
widths[53] = 500; // five
widths[54] = 500; // six
widths[55] = 500; // seven
widths[56] = 500; // eight
widths[57] = 500; // nine
widths[58] = 277; // colon
widths[59] = 277; // semicolon
widths[60] = 563; // less
widths[61] = 563; // equal
widths[62] = 563; // greater
widths[63] = 443; // question
widths[64] = 920; // at
widths[65] = 722; // A
widths[66] = 666; // B
widths[67] = 666; // C
widths[68] = 722; // D
widths[69] = 610; // E
widths[70] = 556; // F
widths[71] = 722; // G
widths[72] = 722; // H
widths[73] = 333; // I
widths[74] = 389; // J
widths[75] = 722; // K
widths[76] = 610; // L
widths[77] = 889; // M
widths[78] = 722; // N
widths[79] = 722; // O
widths[80] = 556; // P
widths[81] = 722; // Q
widths[82] = 666; // R
widths[83] = 556; // S
widths[84] = 610; // T
widths[85] = 722; // U
widths[86] = 722; // V
widths[87] = 943; // W
widths[88] = 722; // X
widths[89] = 722; // Y
widths[90] = 610; // Z
widths[91] = 333; // bracketleft
widths[92] = 277; // backslash
widths[93] = 333; // bracketright
widths[94] = 469; // asciicircum
widths[95] = 500; // underscore
widths[96] = 333; // grave
widths[97] = 443; // a
widths[98] = 500; // b
widths[99] = 443; // c
widths[100] = 500; // d
widths[101] = 443; // e
widths[102] = 333; // f
widths[103] = 500; // g
widths[104] = 500; // h
widths[105] = 277; // i
widths[106] = 277; // j
widths[107] = 500; // k
widths[108] = 277; // l
widths[109] = 777; // m
widths[110] = 500; // n
widths[111] = 500; // o
widths[112] = 500; // p
widths[113] = 500; // q
widths[114] = 333; // r
widths[115] = 389; // s
widths[116] = 277; // t
widths[117] = 500; // u
widths[118] = 500; // v
widths[119] = 722; // w
widths[120] = 500; // x
widths[121] = 500; // y
widths[122] = 443; // z
widths[123] = 479; // braceleft
widths[124] = 200; // bar
widths[125] = 479; // braceright
widths[126] = 541; // asciitilde
widths[160] = 250; // nbspace
widths[161] = 333; // exclamdown
widths[162] = 500; // cent
widths[163] = 500; // sterling
widths[164] = 500; // currency
widths[165] = 500; // yen
widths[166] = 200; // brokenbar
widths[167] = 500; // section
widths[168] = 333; // dieresis
widths[169] = 759; // copyright
widths[170] = 275; // ordfeminine
widths[171] = 500; // guillemotleft
widths[172] = 563; // logicalnot
widths[173] = 333; // sfthyphen
widths[174] = 759; // registered
widths[175] = 500; // overscore
widths[176] = 399; // degree
widths[177] = 548; // plusminus
widths[178] = 299; // twosuperior
widths[179] = 299; // threesuperior
widths[180] = 333; // acute
widths[181] = 576; // mu1
widths[182] = 453; // paragraph
widths[183] = 333; // middot
widths[184] = 333; // cedilla
widths[185] = 299; // onesuperior
widths[186] = 310; // ordmasculine
widths[187] = 500; // guillemotright
widths[188] = 750; // onequarter
widths[189] = 750; // onehalf
widths[190] = 750; // threequarters
widths[191] = 443; // questiondown
widths[192] = 722; // Agrave
widths[193] = 722; // Aacute
widths[194] = 722; // Acircumflex
widths[195] = 722; // Atilde
widths[196] = 722; // Adieresis
widths[197] = 722; // Aring
widths[198] = 889; // AE
widths[199] = 666; // Ccedilla
widths[200] = 610; // Egrave
widths[201] = 610; // Eacute
widths[202] = 610; // Ecircumflex
widths[203] = 610; // Edieresis
widths[204] = 333; // Igrave
widths[205] = 333; // Iacute
widths[206] = 333; // Icircumflex
widths[207] = 333; // Idieresis
widths[208] = 722; // Eth
widths[209] = 722; // Ntilde
widths[210] = 722; // Ograve
widths[211] = 722; // Oacute
widths[212] = 722; // Ocircumflex
widths[213] = 722; // Otilde
widths[214] = 722; // Odieresis
widths[215] = 563; // multiply
widths[216] = 722; // Oslash
widths[217] = 722; // Ugrave
widths[218] = 722; // Uacute
widths[219] = 722; // Ucircumflex
widths[220] = 722; // Udieresis
widths[221] = 722; // Yacute
widths[222] = 556; // Thorn
widths[223] = 500; // germandbls
widths[224] = 443; // agrave
widths[225] = 443; // aacute
widths[226] = 443; // acircumflex
widths[227] = 443; // atilde
widths[228] = 443; // adieresis
widths[229] = 443; // aring
widths[230] = 666; // ae
widths[231] = 443; // ccedilla
widths[232] = 443; // egrave
widths[233] = 443; // eacute
widths[234] = 443; // ecircumflex
widths[235] = 443; // edieresis
widths[236] = 277; // igrave
widths[237] = 277; // iacute
widths[238] = 277; // icircumflex
widths[239] = 277; // idieresis
widths[240] = 500; // eth
widths[241] = 500; // ntilde
widths[242] = 500; // ograve
widths[243] = 500; // oacute
widths[244] = 500; // ocircumflex
widths[245] = 500; // otilde
widths[246] = 500; // odieresis
widths[247] = 548; // divide
widths[248] = 500; // oslash
widths[249] = 500; // ugrave
widths[250] = 500; // uacute
widths[251] = 500; // ucircumflex
widths[252] = 500; // udieresis
widths[253] = 500; // yacute
widths[254] = 500; // thorn
widths[255] = 500; // ydieresis
}
}

View File

@ -75,7 +75,7 @@ public class TreePostScriptGenerator {
protected PostScriptDocument doc;
public TreePostScriptGenerator(@Nullable List<String> ruleNames, Tree root) {
this(ruleNames, root, "CourierNew", 11);
this(ruleNames, root, PostScriptDocument.DEFAULT_FONT, 11);
}
public TreePostScriptGenerator(@Nullable List<String> ruleNames, Tree root,