LogFontとは? わかりやすく解説

LogFont クラス

回転のテキスト効果を作成するためのフォントの特性を定義します。

名前空間: Microsoft.WindowsCE.Forms
アセンブリ: Microsoft.WindowsCE.Forms (microsoft.windowsce.forms.dll 内)
構文構文

解説解説

このクラスは、ネイティブ Windows CE の LOGFONT (論理フォント) 構造体に相当します。この構造体を使用すると、角度およびその他のテキスト効果を作成できます。一部の LogFont フィールドの値は、次の表に示す列挙体によって定義されます。

回転させたテキストを作成するには、LogFont クラスのインスタンスを作成し、Escapement フィールドに必要な回転角度を設定します。Escapement は、角度を 10 分の 1 度単位で指定します。たとえば、45 度の場合、450 を指定します。

Escapement フィールドは、文字送りと文字の方向の両方を指定します。Escapement と Orientation には、同じ値を設定する必要があります。

Windows CE のコンポーネントであるフォント マッパーは、Height フィールドと Weight フィールドに指定した値に最も一致する物理フォントを検索します。

使用例使用例

画面の対角線上にテキストを配置するように、LogFont を定義する方法を次のコード例に示します。

Imports System
Imports System.Drawing
Imports System.Windows.Forms
Imports Microsoft.WindowsCE.Forms



Public Class Form1
    Inherits System.Windows.Forms.Form
    ' Sets screen resolution for targeted device.
    ' If used on high resolution devices with a
    ' DPI of 192, the font will be scaled accordingly.
    Private Const DPISETTING As
 Integer = 96
    
    Private rotatedFont As Font
    Private redBrush As SolidBrush
    
    
    Public Sub New() 
        ' Display OK button to close application.
        Me.MinimizeBox = False
        Me.Text = "Rotated Font"
        
        ' Create Font and Brush objects in the constructor,
        ' so they can be resued when the form is repainted.
        Me.rotatedFont = CreateRotatedFont("Tahoma",
 45)
        Me.redBrush = New SolidBrush(Color.Red)
    
    End Sub
    
    
    ' Create an rotated font using a LOGFONT structure.
    Function CreateRotatedFont(ByVal fontname
 As String, ByVal angleInDegrees
 As Integer) As Font 
        Dim lf As New LogFont()
        
        ' Create graphics object for the form.
        Dim g As Graphics = Me.CreateGraphics()
        
        ' Scale a 12 point font for current screen DPI.
        lf.Height = Fix(- 16F * g.DpiY / DPISETTING)
        
        ' Convert rotation angle to tenths of degrees.
        lf.Escapement = angleInDegrees * 10
        
        ' Orientation is the same as
        ' Escapement in mobile platforms.
        lf.Orientation = lf.Escapement
        
        lf.Width = 0
        lf.Weight = 0
        lf.Italic = 0
        lf.Underline = 0
        lf.StrikeOut = 0
        lf.CharSet = LogFontCharSet.Default
        lf.OutPrecision = LogFontPrecision.Default
        lf.ClipPrecision = LogFontClipPrecision.Default
        lf.Quality = LogFontQuality.ClearType
        lf.PitchAndFamily = LogFontPitchAndFamily.Default
        lf.FaceName = fontname
        
        Return System.Drawing.Font.FromLogFont(lf)

        ' Explicitly dispose any drawing objects created.
        g.Dispose()
        
    
    End Function
    
    
    Protected Overrides Sub
 OnPaint(ByVal e As PaintEventArgs) 
        If Me.rotatedFont Is
 Nothing Then
            Return
        End If 
        ' Draw the text to the screen using the LogFont
        ' Starting at specified coordinates on the screen.
        e.Graphics.DrawString("abc ABC 123", Me.rotatedFont,
 Me.redBrush, 10, 125, New StringFormat(StringFormatFlags.NoWrap
 Or StringFormatFlags.NoClip))
    
    End Sub
    
    
    Protected Overrides Sub
 Dispose(ByVal disposing As Boolean)
 
        MyBase.Dispose(disposing)
        
        ' Dispose created graphic objects.
        ' Although disposed by the Garbage
        ' Collector when the application
        ' terminates, a good practice is to dispose
        ' them when they are no longer needed.
        Me.redBrush.Dispose()
        Me.rotatedFont.Dispose()
    
    End Sub
    
    
    Shared Sub Main() 
        Application.Run(New Form1())
    
    End Sub
End Class
using System;
using System.Drawing;
using System.Windows.Forms;
using Microsoft.WindowsCE.Forms;

namespace LogFontDemo
{
    public class Form1 : System.Windows.Forms.Form
    {
        // Sets screen resolution for targeted device.
        // If used on high resolution devices with a
        // DPI of 192, the font will be scaled accordingly.
        const int DPISETTING = 96;

        Font rotatedFont;
        SolidBrush redBrush;

        public Form1()
        {
            // Display OK button to close application.
            this.MinimizeBox = false;
            this.Text = "Rotated Font";

            // Create Font and Brush objects in the constructor,
            // so they can be resued when the form is repainted.
            this.rotatedFont = CreateRotatedFont("Tahoma",
 45);
            this.redBrush    = new SolidBrush(Color.Red);
        }

        // Create an rotated font using a LOGFONT structure.
        Font CreateRotatedFont(string fontname, int
 angleInDegrees)
        {
            LogFont lf = new LogFont();

            // Create graphics object for the form.
            Graphics g = this.CreateGraphics();

            // Scale a 12 point font for current screen DPI.
            lf.Height = (int)(-16f * g.DpiY / DPISETTING);

            // Convert rotation angle to tenths of degrees.
            lf.Escapement = angleInDegrees * 10;

            // Orientation is the same as
            // Escapementin mobile platforms.
            lf.Orientation = lf.Escapement;

            lf.Width     = 0;
            lf.Weight    = 0;
            lf.Italic    = 0;
            lf.Underline = 0;
            lf.StrikeOut = 0;
            lf.CharSet        = LogFontCharSet.Default;
            lf.OutPrecision   = LogFontPrecision.Default;
            lf.ClipPrecision  = LogFontClipPrecision.Default;
            lf.Quality        = LogFontQuality.ClearType;
            lf.PitchAndFamily = LogFontPitchAndFamily.Default;
            lf.FaceName       = fontname;

            return Font.FromLogFont(lf);

            // Explicitly dispose any drawing objects created.
            g.Dispose();

        }

        protected override void OnPaint(PaintEventArgs
 e)
        {
            if(this.rotatedFont == null)
                return;

            // Draw the text to the screen using the LogFont
            // Starting at specified coordinates on the screen.
            e.Graphics.DrawString("abc ABC 123",
                this.rotatedFont,
                this.redBrush,
                10,
                125,
                new StringFormat(StringFormatFlags.NoWrap |
                     StringFormatFlags.NoClip));
        }

        protected override void Dispose(bool
 disposing)
        {
            base.Dispose(disposing);

            // Dispose created graphic objects.
            // Although disposed by the Garbage
            // Collector when the application
            // terminates, a good practice is to dispose
            // them when they are no longer needed.
            this.redBrush.Dispose();
            this.rotatedFont.Dispose();
        }

        static void Main()
        {
            Application.Run(new Form1());
        }
    }
}
継承階層継承階層
System.Object
  Microsoft.WindowsCE.Forms.LogFont
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

LogFont コンストラクタ


LogFont フィールド


パブリック フィールドパブリック フィールド

参照参照

関連項目

LogFont クラス
Microsoft.WindowsCE.Forms 名前空間

その他の技術情報

LogFont を使用したテキストの回転のサンプル

LogFont メソッド


LogFont メンバ

回転のテキスト効果を作成するためのフォントの特性を定義します。

LogFont データ型で公開されるメンバを以下の表に示します。


パブリック コンストラクタパブリック コンストラクタ
パブリック フィールドパブリック フィールド
パブリック メソッドパブリック メソッド
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

LogFont クラス
Microsoft.WindowsCE.Forms 名前空間

その他の技術情報

LogFont を使用したテキストの回転のサンプル



英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

「LogFont」の関連用語

LogFontのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



LogFontのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS