質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
WPF

Windows Presentation Foundation (WPF) は、魅力的な外観のユーザー エクスペリエンスを持つ Windows クライアント アプリケーションを作成するための次世代プレゼンテーション システムです

Q&A

解決済

1回答

2672閲覧

WPFでプリントすると'C:\WINDOWS\FONTS\YUGOTHM.TTC'を開いているときにI/Oエラーが発生する。

cancat

総合スコア313

WPF

Windows Presentation Foundation (WPF) は、魅力的な外観のユーザー エクスペリエンスを持つ Windows クライアント アプリケーションを作成するための次世代プレゼンテーション システムです

0グッド

0クリップ

投稿2017/03/08 05:59

こんにちは。
Windows10でWPFのアプリケーションを開発しています。
Visual Studio 2015 Communityを使っています。

###前提・実現したいこと
プリントをしたいです。
下記のエラーが出ます。
そもそもYugothm.ttcなど使っていないのです。

###発生している問題・エラーメッセージ
「Print Error 印刷処理
ファイル'C:\WINDOWS\FONTS\YUGOTHM.TTC'を開いているときにI/Oエラーが発生しました。」

場所 MS.Internal.FontCache.FileMapping.OpenFile(String fileName)
場所 MS.Internal.FontCache.FontSource.GetUnmanagedStream()
場所 System.Windows.Media.GlyphTypeface.ComputeSubset(ICollection1 glyphs) 場所 System.Windows.Xps.Serialization.FEMCacheItem.SubSetFont(ICollection1 glyphs, Stream stream)
場所 System.Windows.Xps.Serialization.FEMCacheItem.Commit()
場所 System.Windows.Xps.Serialization.XpsFontSubsetter.CommitFontSubsetsSignal(FontSubsetterCommitPolicies signal)
場所 System.Windows.Xps.Serialization.XpsFontSerializationService.SignalCommit(Type type)
場所 System.Windows.Xps.Serialization.XpsSerializationManager.ReleaseXmlWriter(Type writerType)
場所 System.Windows.Xps.Serialization.DocumentPaginatorSerializer.set_XmlWriter(XmlWriter value)
場所 System.Windows.Xps.Serialization.DocumentPaginatorSerializer.PersistObjectData(SerializableObjectContext serializableObjectContext)
場所 System.Windows.Xps.Serialization.DocumentPaginatorSerializer.SerializeObject(Object serializedObject)
場所 System.Windows.Xps.Serialization.XpsSerializationManager.SaveAsXaml(Object serializedObject)
場所 System.Windows.Xps.XpsDocumentWriter.SaveAsXaml(Object serializedObject, Boolean isSync)
場所 System.Windows.Xps.XpsDocumentWriter.Write(DocumentPaginator documentPaginator, PrintTicket printTicket)
場所 System.Windows.Controls.PrintDialog.PrintDocument(DocumentPaginator documentPaginator, String description)

###該当のソースコード

xaml

1<Window x:Class="WpfApplication1.MainWindow" 2 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 3 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 4 xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 5 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 6 xmlns:local="clr-namespace:WpfApplication1" 7 mc:Ignorable="d" 8 Title="MainWindow" Height="350" Width="525" 9x:Name="mainwindow" 10> 11 <Canvas x:Name="testcanvas" Height="200" Width="200" Background="AliceBlue"> 12 <TextBox x:Name="text0" Text="テスト" FontFamily="Meiryo"/> 13 <Button x:Name="testbutton" Click="testbutton_Click" Content="Button" HorizontalAlignment="Left" Height="35" VerticalAlignment="Top" Width="75" Canvas.Left="115" Canvas.Top="28"/> 14 </Canvas> 15</Window>

C#

1using System; 2using System.Windows; 3using System.Windows.Controls; 4using System.Windows.Documents; 5using System.Printing; 6 7namespace WpfApplication1 { 8 public partial class MainWindow : Window { 9 public MainWindow() { 10 InitializeComponent(); 11 } 12 13 PrintDialog printdialog = new PrintDialog(); 14 private void testbutton_Click(object sender, RoutedEventArgs e) { 15 var printDialog = new PrintDialog(); 16 using (var printQueue = new LocalPrintServer().DefaultPrintQueue) { 17 printDialog.PrintQueue = printQueue; 18 var area = printDialog.PrintQueue.GetPrintCapabilities(); 19 if (area.PageImageableArea == null) throw new Exception("Failed to load printer settings."); 20 var flowDocument = new FlowDocument { 21 PagePadding = new Thickness( 22 area.PageImageableArea.OriginWidth, 23 area.PageImageableArea.OriginWidth, 24 0, 25 0), 26 PageWidth = area.PageImageableArea.ExtentWidth + area.PageImageableArea.OriginWidth 27 }; 28 29 Canvas canvas = new Canvas(); 30 TextBox textbox = new TextBox(); 31 textbox.Text = text0.Text; 32 canvas.Children.Add(textbox); 33 var container = new BlockUIContainer(canvas); 34 flowDocument.Blocks.Add(container); 35 var paginator = ((IDocumentPaginatorSource)flowDocument).DocumentPaginator; 36try{ 37 printDialog.PrintDocument(paginator, "A Flow Document");<--ここでerror 38} 39catch(Exception exception){ 40 MessageBox.Show("exception.Message + exception.InnerException.Message); 41} 42 } 43 } 44 } 45}

###補足情報(言語/FW/ツール等のバージョンなど)
Microsoft Visual Studio Community 2015
Version 14.0.25424.00 Update 3
Microsoft .NET Framework
Version 4.6.01038

インストールしているバージョン:Community

Visual C# 2015 00322-20000-00000-AA575
Microsoft Visual C# 2015

です。
よろしくお願いします。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

Yugothm.ttcは游ゴシックです。
Windows 10の環境ではデフォルトが游ゴシックです。
ですのでButtonの文字列の描画で使用されているかもしれません。
Yugothm.ttcがなぜ開けないのかは記載されているエラーメッセージだけからでは分かりませんが
WindowやButtonのFontFamily属性を変更してみてはどうでしょうか?

投稿2017/03/08 14:14

hmmm

総合スコア818

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

cancat

2017/03/10 01:10

ありがとうございます。 デフォルトだからなのですよね。 わたしも、このエラーだけで原因を特定できず、途方に暮れているところです。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問