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

LogFont クラス

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

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

解説解説

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

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

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

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) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「LogFont クラス」の関連用語

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

   

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



LogFont クラスのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2024 GRAS Group, Inc.RSS