root/java/org/gnu/emacs/EmacsFontDriver.java

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. toString
  2. toString
  3. list
  4. match
  5. listFamilies
  6. openFont
  7. hasChar
  8. textExtents
  9. encodeChar
  10. draw
  11. createFontDriver

     1 /* Font backend for Android terminals.  -*- c-file-style: "GNU" -*-
     2 
     3 Copyright (C) 2023 Free Software Foundation, Inc.
     4 
     5 This file is part of GNU Emacs.
     6 
     7 GNU Emacs is free software: you can redistribute it and/or modify
     8 it under the terms of the GNU General Public License as published by
     9 the Free Software Foundation, either version 3 of the License, or (at
    10 your option) any later version.
    11 
    12 GNU Emacs is distributed in the hope that it will be useful,
    13 but WITHOUT ANY WARRANTY; without even the implied warranty of
    14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    15 GNU General Public License for more details.
    16 
    17 You should have received a copy of the GNU General Public License
    18 along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.  */
    19 
    20 package org.gnu.emacs;
    21 
    22 import android.os.Build;
    23 
    24 /* This code is mostly unused.  See sfntfont-android.c for the code
    25    that is actually used.  */
    26 
    27 public abstract class EmacsFontDriver
    28 {
    29   /* Font weights.  */
    30   public static final int THIN          = 0;
    31   public static final int ULTRA_LIGHT   = 40;
    32   public static final int LIGHT         = 50;
    33   public static final int SEMI_LIGHT    = 55;
    34   public static final int REGULAR       = 80;
    35   public static final int MEDIUM        = 100;
    36   public static final int SEMI_BOLD     = 180;
    37   public static final int BOLD          = 200;
    38   public static final int EXTRA_BOLD    = 205;
    39   public static final int BLACK         = 210;
    40   public static final int ULTRA_HEAVY   = 250;
    41 
    42   /* Font slants.  */
    43   public static final int REVERSE_OBLIQUE       = 0;
    44   public static final int REVERSE_ITALIC        = 10;
    45   public static final int NORMAL                = 100;
    46   public static final int ITALIC                = 200;
    47   public static final int OBLIQUE               = 210;
    48 
    49   /* Font widths.  */
    50   public static final int ULTRA_CONDENSED       = 50;
    51   public static final int EXTRA_CONDENSED       = 63;
    52   public static final int CONDENSED             = 75;
    53   public static final int SEMI_CONDENSED        = 87;
    54   public static final int UNSPECIFIED           = 100;
    55   public static final int SEMI_EXPANDED         = 113;
    56   public static final int EXPANDED              = 125;
    57   public static final int EXTRA_EXPANDED        = 150;
    58   public static final int ULTRA_EXPANDED        = 200;
    59 
    60   /* Font spacings.  */
    61   public static final int PROPORTIONAL  = 0;
    62   public static final int DUAL          = 90;
    63   public static final int MONO          = 100;
    64   public static final int CHARCELL      = 110;
    65 
    66   public static class FontSpec
    67   {
    68     /* The fields below mean the same as they do in enum
    69        font_property_index in font.h.  */
    70 
    71     public String foundry;
    72     public String family;
    73     public String adstyle;
    74     public String registry;
    75     public Integer width;
    76     public Integer weight;
    77     public Integer slant;
    78     public Integer size;
    79     public Integer spacing;
    80     public Integer avgwidth;
    81     public Integer dpi;
    82 
    83     @Override
    84     public String
    85     toString ()
    86     {
    87       return ("foundry: " + foundry
    88               + " family: " + family
    89               + " adstyle: " + adstyle
    90               + " registry: " + registry
    91               + " width: " + width
    92               + " weight: " + weight
    93               + " slant: " + slant
    94               + " spacing: " + spacing
    95               + " avgwidth: " + avgwidth
    96               + " dpi: " + dpi);
    97     }
    98   };
    99 
   100   public static class FontMetrics
   101   {
   102     public short lbearing;
   103     public short rbearing;
   104     public short width;
   105     public short ascent;
   106     public short descent;
   107 
   108     @Override
   109     public String
   110     toString ()
   111     {
   112       return ("lbearing " + lbearing
   113               + " rbearing " + rbearing
   114               + " width " + width
   115               + " ascent " + ascent
   116               + " descent " + descent);
   117     }
   118   }
   119 
   120   public static class FontEntity extends FontSpec
   121   {
   122     /* No extra fields here.  */
   123   };
   124 
   125   public abstract class FontObject extends FontSpec
   126   {
   127     public int minWidth;
   128     public int maxWidth;
   129     public int pixelSize;
   130     public int height;
   131     public int spaceWidth;
   132     public int averageWidth;
   133     public int ascent;
   134     public int descent;
   135     public int underlineThickness;
   136     public int underlinePosition;
   137     public int baselineOffset;
   138     public int relativeCompose;
   139     public int defaultAscent;
   140     public int encodingCharset;
   141     public int repertoryCharset;
   142 
   143     public
   144     FontObject ()
   145     {
   146       encodingCharset = -1;
   147       repertoryCharset = -1;
   148     }
   149   };
   150 
   151   /* These mean the same as they do in struct font_driver.  */
   152   public abstract FontEntity[] list (FontSpec fontSpec);
   153   public abstract FontEntity match (FontSpec fontSpec);
   154   public abstract String[] listFamilies ();
   155   public abstract FontObject openFont (FontEntity fontEntity, int pixelSize);
   156   public abstract int hasChar (FontSpec font, char charCode);
   157   public abstract void textExtents (FontObject font, int code[],
   158                                     FontMetrics fontMetrics);
   159   public abstract int encodeChar (FontObject fontObject, char charCode);
   160   public abstract int draw (FontObject fontObject, EmacsGC gc,
   161                             EmacsDrawable drawable, int[] chars,
   162                             int x, int y, int backgroundWidth,
   163                             boolean withBackground);
   164 
   165   public static EmacsFontDriver
   166   createFontDriver ()
   167   {
   168     if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
   169       return new EmacsSdk23FontDriver ();
   170 
   171     return new EmacsSdk7FontDriver ();
   172   }
   173 };

/* [<][>][^][v][top][bottom][index][help] */