Imported Upstream version 3.6.0

Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
This commit is contained in:
Jo Shields
2014-08-13 10:39:27 +01:00
commit a575963da9
50588 changed files with 8155799 additions and 0 deletions

View File

@@ -0,0 +1,143 @@
2007-05-21 Adar Wesley <adarw@mainsoft.com>
* LineLayout.jvm.cs: change MemberwiseClone to clone.
2006-08-25 Sebastien Pouliot <sebastien@ximian.com>
* PrivateFontCollection.cs: Fix warning by reusing the full path.
2006-08-07 Andrew Skiba <andrews@mainsoft.com>
* LineLayout.jvm.cs: TARGET_JVM fix
2006-05-30 Sebastien Pouliot <sebastien@ximian.com>
* FontCollection.cs: Avoid calling GdipGetFontCollectionFamilyList
when GdipGetFontCollectionFamilyCount returns a count of 0 items.
2006-05-21 Sebastien Pouliot <sebastien@ximian.com>
* GenericFontFamilies.cs: Removed [Serializable] from 2.0 profile.
* HotkeyPrefix.cs: Removed [Serializable] from 2.0 profile.
* TextRenderingHint.cs: Removed [Serializable] from 2.0 profile.
2006-04-13 Sebastien Pouliot <sebastien@ximian.com>
* FontCollection.cs: Remove unused ctor. Throw on disposed (private)
collections. Don't dispose (but leak) under non-Windows OS.
* InstalledFontCollection.cs: Remove unused ctor.
* PrivateFontCollection.cs: Remove unused ctor. Fix exceptions to
match unit tests.
2006-03-23 Peter Dennis Bartok <pbartok@novell.com>
* FontCollection.cs (Dispose): When on Linux/Unix, call
GdipDeletePrivateFontCollection to free up the font collection (even
though it's not private, we'd be leaking otherwise. Don't try this
with Microsoft's GDI+ on Win32, though.)
2006-03-23 Peter Dennis Bartok <pbartok@novell.com>
* FontCollection.cs (get_Families): Now letting the runtime do the
marshalling work for us. Easier to maintain and cleaner code.
* PrivateFontCollection.cs:
- AddFontFile: Fixed weird english in error message
- Dispose: Need to pass ref to the native object, we were crashing
badly
2006-02-09 Peter Dennis Bartok <pbartok@novell.com>
* ChangeLog: Created, contents from deleted 'changelog' file
* FontCollection.cs: Cleaned up marshalling and made 64bit safe
2005-12-13 Konstantin Triger <kostat@mainsoft.com>
* TextLineIterator.jvm.cs: handle null string.
2005-11-16 Konstantin Triger <kostat@mainsoft.com>
* PrivateFontCollection.jvm.cs: open a correct stream.
2005-11-13 Konstantin Triger <kostat@mainsoft.com>
* Added LineLayout.jvm.cs, TextLineIterator.jvm.cs for text support
2005-11-10 Vladimir Krasnov <vladimirk@mainsoft.com>
* FontCollection.jvm.cs: refactoring, added GetInitialFont()
* InstalledFontCollection.jvm.cs: refactoring, removed GetFamilyName
* PrivateFontCollection.jvm.cs: refactoring
2005-08-03 Andrew Skiba <andrews@mainsoft.com>
* FontCollection.jvm.cs, InstalledFontCollection.jvm.cs,
PrivateFontCollection.jvm.cs: added TARGET_JVM implementation
2005-04-04 Jordi Mas i Hernandez <jordi@ximian.com>
* PrivateFontCollection.cs: nativeFontCollection equals IntPtr.Zero to
avoid errors on multiple disposes
* FontCollection.cs: implements dispose
2004-11-25 Marek Safar <marek.safar@seznam.cz>
* Image.cs: Add CheckStatus to Families.
2004-02-25 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
* PrivateFontCollection.cs: Removed excess attributes
2004-02-25 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
* FontCollection.cs: Remove console
2004-02-06 Sanjay Gupta <gsanjay@novell.com>
* CheckStatus(): Used method of GDIPlus for error checking
in FontCollection.cs, InstalledFontCollection.cs and
PrivateFontCollection.cs
2004-01-29 Sanjay Gupta <gsanjay@novell.com>
* FontCollection.cs: Implemented Dispose method.
* InstalledFontCollection.cs: Removed Console.WriteLine calls.
* PrivateFontCollection.cs: Implemented AddMemoryFont method.
2004-01-28 Jordi Mas <jordi@ximian.com>
* FontCollection.cs: fixed marshalling issues
2004-01-28 Sanjay Gupta <gsanjay@novell.com>
* FontCollection.cs: Implemented missing functionalities.
* InstalledFontCollection.css: Implemented missing functionalities.
* PrivateFontCollection.cs: Implemented few methods.
2004-01-10 Ravindra <rkumar@novell.com>
* All Enums: Made serializable.
2003-10-12 Alexandre Pigolkine <pigolkine@gmx.de>
* InstalledFontCollection.cs factory removed
2003-06-22 Alexandre Pigolkine <pigolkine@gmx.de>
* FontCollection.cs
* InstalledFontCollection.cs
calls to implementation added
2002-09-16 Nick Drochak <ndrochak@gol.com>
* PrivateFontCollection.cs: Fix build error. Cannot put ComVisible on
constructors.
2003-09-14 Piers Haken <piersh@friskit.com>
* PrivateFontCollection.cs: import interop for ComVisible attribute
2002-09-13 Dennis Hayes (dennish@raytek.com)
* checked in for Everaldo Canuto everaldo.canuto@bol.com.br
* FontCollection.cs
* GenericFontFamilies.cs
* HotkeyPrefix.cs
* InstalledFontCollection.cs
* PrivateFontCollection.cs
* TextRenderingHint.cs

View File

@@ -0,0 +1,92 @@
//
// System.Drawing.Text.FontCollection.cs
//
// (C) 2002 Ximian, Inc. http://www.ximian.com
// Author: Everaldo Canuto everaldo.canuto@bol.com.br
// Sanjay Gupta (gsanjay@novell.com)
// Peter Dennis Bartok (pbartok@novell.com)
//
//
// Copyright (C) 2004 - 2006 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace System.Drawing.Text {
public abstract class FontCollection : IDisposable {
internal IntPtr nativeFontCollection = IntPtr.Zero;
internal FontCollection ()
{
}
// methods
public void Dispose()
{
Dispose (true);
GC.SuppressFinalize (true);
}
protected virtual void Dispose (bool disposing)
{
// DO NOT FREE FROM HERE
// FIXME: InstalledFontCollection cannot be freed safely and will leak one time
// (inside libgdiplus). MS has a similar behaviour (but probably doesn't leak)
}
// properties
public FontFamily[] Families
{
get {
int found;
int returned = 0;
Status status;
FontFamily[] families;
IntPtr[] result;
// MS doesn't throw ObjectDisposedException in this case
if (nativeFontCollection == IntPtr.Zero)
throw new ArgumentException (Locale.GetText ("Collection was disposed."));
status = GDIPlus.GdipGetFontCollectionFamilyCount (nativeFontCollection, out found);
GDIPlus.CheckStatus (status);
if (found == 0)
return new FontFamily [0];
result = new IntPtr[found];
status = GDIPlus.GdipGetFontCollectionFamilyList (nativeFontCollection, found, result, out returned);
families = new FontFamily [returned];
for ( int i = 0; i < returned ; i++) {
families[i] = new FontFamily(result[i]);
}
return families;
}
}
~FontCollection()
{
Dispose (false);
}
}
}

View File

@@ -0,0 +1,89 @@
//
// System.Drawing.Text.FontCollection.cs
//
// (C) 2002 Ximian, Inc. http://www.ximian.com
// Author: Everaldo Canuto everaldo.canuto@bol.com.br
// Sanjay Gupta (gsanjay@novell.com)
//
//
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections;
using System.Collections.Specialized;
using awt = java.awt;
namespace System.Drawing.Text
{
/// <summary>
/// Summary description for FontCollection.
/// </summary>
public abstract class FontCollection : IDisposable
{
private readonly Hashtable _fonts;
protected FontCollection()
{
_fonts = CollectionsUtil.CreateCaseInsensitiveHashtable( new Hashtable() );
}
protected FontCollection(Hashtable fonts) {
_fonts = fonts;
}
public FontFamily[] Families {
get {
ICollection values = _fonts.Keys;
FontFamily[] families = new FontFamily[values.Count];
string [] keys = new string[_fonts.Count];
_fonts.Keys.CopyTo(keys, 0);
for (int i = 0; i < _fonts.Count; i++)
families[i] = new FontFamily( keys[i] );
return families;
}
}
internal virtual awt.Font GetInitialFont(string familyName) {
return (awt.Font)_fonts[familyName];
}
internal virtual bool Contains(string familyName) {
return _fonts.ContainsKey( familyName );
}
protected void AddFont(awt.Font font) {
_fonts.Add(font.getFamily(), font);
}
#region IDisposable Members
public void Dispose() {
// TODO: Add FontCollection.Dispose implementation
}
#endregion
}
}

View File

@@ -0,0 +1,39 @@
//
// System.Drawing.GenericFontFamilies.cs
//
// Author: Dennis Hayes (dennish@raytek.com)
//
// (C) 2002 Ximian, Inc. http://www.ximian.com
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace System.Drawing.Text {
#if ONLY_1_1
[Serializable]
#endif
public enum GenericFontFamilies {
Monospace = 2,
SansSerif = 1,
Serif = 0
}
}

View File

@@ -0,0 +1,39 @@
//
// System.Drawing.HotkeyPrefix.cs
//
// Author: Dennis Hayes (dennish@raytek.com)
//
// (C) 2002 Ximian, Inc. http://www.ximian.com
// Copyright (C) 2004,2006 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace System.Drawing.Text {
#if ONLY_1_1
[Serializable]
#endif
public enum HotkeyPrefix {
Hide = 2,
None = 0,
Show = 1
}
}

View File

@@ -0,0 +1,41 @@
//
// System.Drawing.Text.InstalledFontCollection.cs
//
// (C) 2002 Ximian, Inc. http://www.ximian.com
// Author: Everaldo Canuto everaldo.canuto@bol.com.br
// Alexandre Pigolkine ( pigolkine@gmx.de)
// Sanjay Gupta (gsanjay@novell.com)
//
// Copyright (C) 2004, 2006 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace System.Drawing.Text {
public sealed class InstalledFontCollection : FontCollection {
public InstalledFontCollection ()
{
Status status = GDIPlus.GdipNewInstalledFontCollection (out nativeFontCollection);
GDIPlus.CheckStatus (status);
}
}
}

View File

@@ -0,0 +1,57 @@
//
// System.Drawing.InstalledFontCollection.cs
//
// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com)
// Author: Konstantin Triger (kostat@mainsoft.com)
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections;
using System.Collections.Specialized;
using awt = java.awt;
namespace System.Drawing.Text
{
/// <summary>
/// Summary description for InstalledFontCollection.
/// </summary>
public sealed class InstalledFontCollection : FontCollection
{
static readonly Hashtable _installedFonts;
static InstalledFontCollection()
{
_installedFonts = CollectionsUtil.CreateCaseInsensitiveHashtable( new Hashtable() );
java.awt.Font [] fonts = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
for (int i = 0; i < fonts.Length; i++) {
string fontFamilyName = fonts[i].getFamily();
if (!_installedFonts.ContainsKey( fontFamilyName ))
_installedFonts.Add(fontFamilyName, fonts[i]);
}
}
public InstalledFontCollection() : base( _installedFonts ) {
}
}
}

View File

@@ -0,0 +1,193 @@
//
// System.Drawing.Test.LineLayout.jvm.cs
//
// Author:
// Konstantin Triger <kostat@mainsoft.com>
//
// Copyright (C) 2005 Mainsoft Corporation, (http://www.mainsoft.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Drawing.Drawing2D;
using font = java.awt.font;
using text = java.text;
using awt = java.awt;
using geom = java.awt.geom;
namespace System.Drawing.Text {
internal sealed class LineLayout {
#region Fields
readonly font.TextLayout _layout;
readonly float _accumulatedHeight;
readonly TextLineIterator _lineIter;
#endregion
#region ctor
internal LineLayout(font.TextLayout layout,
TextLineIterator lineIter,
float accumulatedHeight) {
_layout = layout;
_lineIter = lineIter;
_accumulatedHeight = accumulatedHeight;
}
#endregion
#region Properties
internal float AccumulatedHeight {
get { return _accumulatedHeight; }
}
internal float MeasureWidth {
get {
return _lineIter.PadWidth (Width);
}
}
internal float WidthPadding {
get {
return _lineIter.PadWidth (Width) - Width;
}
}
internal int CharacterCount {
get { return _layout.getCharacterCount(); }
}
internal float Ascent {
get { return _layout.getAscent(); }
}
internal float Descent {
get { return _layout.getDescent(); }
}
public float Leading {
get { return _layout.getLeading(); }
}
internal float NativeY {
get {
if (_lineIter.Format.IsVertical) {
float height = _lineIter.Height;
if (float.IsPositiveInfinity(height))
height = 0;
switch (_lineIter.Format.Alignment) {
case StringAlignment.Center:
return (height - Width) / 2;
case StringAlignment.Far:
return height - _layout.getVisibleAdvance () - WidthPadding;
default:
return WidthPadding;
}
}
else
return AccumulatedHeight + Ascent;
}
}
internal float NativeX {
get {
float width = _lineIter.Width;
if (float.IsPositiveInfinity(width))
width = 0;
if (_lineIter.Format.IsVertical)
return (_lineIter.Format.IsRightToLeft) ?
width - AccumulatedHeight - Ascent :
AccumulatedHeight + Leading + Descent;
else {
float xOffset;
switch ( _lineIter.Format.Alignment) {
case StringAlignment.Center:
xOffset = (width - Width) / 2;
break;
case StringAlignment.Far:
if (_lineIter.Format.IsRightToLeft)
xOffset = WidthPadding/2;
else
xOffset = width - _layout.getVisibleAdvance () - WidthPadding/2;
break;
default:
if (_lineIter.Format.IsRightToLeft)
xOffset = width - _layout.getVisibleAdvance () - WidthPadding/2;
else
xOffset = WidthPadding / 2;
break;
}
return xOffset;
}
}
}
internal float Height {
get {
return Ascent + Descent + Leading;
}
}
internal float Width {
get {
if (_lineIter.Format.MeasureTrailingSpaces)
if (!(_lineIter.Format.IsRightToLeft ^
(_lineIter.Format.Alignment == StringAlignment.Far)))
return _layout.getAdvance();
return _layout.getVisibleAdvance();
}
}
#endregion
#region Methods
internal void Draw(awt.Graphics2D g2d, float x, float y) {
if (_lineIter.Format.IsVertical)
_layout.draw (g2d, y + NativeY, -(x + NativeX));
else
_layout.draw(g2d, x + NativeX, y + NativeY );
}
internal awt.Shape GetOutline(float x, float y) {
geom.AffineTransform t = (geom.AffineTransform) _lineIter.Transform.clone();
if (_lineIter.Format.IsVertical)
t.translate(y + NativeY, -(x + NativeX));
else
t.translate(x + NativeX, y + NativeY);
return _layout.getOutline(t);
}
#endregion
}
}

View File

@@ -0,0 +1,91 @@
//
// System.Drawing.Text.PrivateFontCollection.cs
//
// (C) 2002 Ximian, Inc. http://www.ximian.com
// Author: Everaldo Canuto everaldo.canuto@bol.com.br
// Sanjay Gupta (gsanjay@novell.com)
// Peter Dennis Bartok (pbartok@novell.com)
//
//
// Copyright (C) 2004 - 2006 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.IO;
using System.Security.Permissions;
using System.Runtime.InteropServices;
namespace System.Drawing.Text {
#if !NET_2_0
[ComVisible(false)]
#endif
public sealed class PrivateFontCollection : FontCollection {
// constructors
public PrivateFontCollection ()
{
Status status = GDIPlus.GdipNewPrivateFontCollection (out nativeFontCollection);
GDIPlus.CheckStatus (status);
}
// methods
public void AddFontFile (string filename)
{
if (filename == null)
throw new ArgumentNullException ("filename");
// this ensure the filename is valid (or throw the correct exception)
string fname = Path.GetFullPath (filename);
if (!File.Exists (fname))
throw new FileNotFoundException ();
// note: MS throw the same exception FileNotFoundException if the file exists but isn't a valid font file
Status status = GDIPlus.GdipPrivateAddFontFile (nativeFontCollection, fname);
GDIPlus.CheckStatus (status);
}
[SecurityPermission (SecurityAction.Demand, UnmanagedCode = true)]
public void AddMemoryFont (IntPtr memory, int length)
{
// note: MS throw FileNotFoundException if something is bad with the data (except for a null pointer)
Status status = GDIPlus.GdipPrivateAddMemoryFont (nativeFontCollection, memory, length);
GDIPlus.CheckStatus (status);
}
// methods
protected override void Dispose (bool disposing)
{
if (nativeFontCollection!=IntPtr.Zero) {
GDIPlus.GdipDeletePrivateFontCollection (ref nativeFontCollection);
// This must be zeroed out, otherwise our base will also call
// the GDI+ delete method on unix platforms. We're keeping the
// base.Dispose() call in case other cleanup ever gets added there
nativeFontCollection = IntPtr.Zero;
}
base.Dispose (disposing);
}
}
}

View File

@@ -0,0 +1,58 @@
//
// System.Drawing.PrivateFontCollection.cs
//
// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com)
// Author: Konstantin Triger (kostat@mainsoft.com)
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.IO;
using awt = java.awt;
using io = java.io;
using vmw.common;
namespace System.Drawing.Text
{
/// <summary>
/// Summary description for PrivateFontCollection.
/// </summary>
public sealed class PrivateFontCollection : FontCollection
{
public PrivateFontCollection()
{
}
public void AddFontFile(string filename) {
using(FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read)) {
io.InputStream stream = vmw.common.IOUtils.ToInputStream (fs);
awt.Font font = awt.Font.createFont(awt.Font.TRUETYPE_FONT, stream);
AddFont(font);
}
}
#if INTPTR_SUPPORT
public void AddMemoryFont(IntPtr memory, int length) {
}
#endif
}
}

View File

@@ -0,0 +1,277 @@
//
// System.Drawing.Test.TextLineIterator.jvm.cs
//
// Author:
// Konstantin Triger <kostat@mainsoft.com>
//
// Copyright (C) 2005 Mainsoft Corporation, (http://www.mainsoft.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Drawing.Drawing2D;
using font = java.awt.font;
using text = java.text;
using awt = java.awt;
using geom = java.awt.geom;
namespace System.Drawing.Text {
internal sealed class TextLineIterator {
#region Fields
readonly float _width;
readonly float _height;
readonly StringFormat _format;
readonly font.FontRenderContext _frc;
readonly string _s;
readonly Font _font;
readonly float _margin;
static readonly string NewLine;
static readonly geom.AffineTransform Rotate90Transform =
geom.AffineTransform.getRotateInstance(Math.PI/2);
font.TextMeasurer _measurer;
int _charsConsumed = 0;
int _currentPos = 0;
int _currentRun = 0;
float _accumulatedHeight = 0;
#endregion
#region ctors
static TextLineIterator() {
string newLine = Environment.NewLine;
if (newLine == null || newLine.Length == 0 || newLine[newLine.Length - 1] == '\n')
newLine = "\n";
NewLine = newLine;
}
internal TextLineIterator(string s, Font font, font.FontRenderContext frc, StringFormat format, float width, float height) {
_format = (format != null) ? format : new StringFormat();
_font = font;
_s = (s != null) ? s : String.Empty;
_frc = frc;
FontFamily ff = font.FontFamily;
_margin = font.Size*ff.GetDrawMargin(font.Style)/ff.GetEmHeight(font.Style);
_width = width;
_height = height;
}
#endregion
#region Properties
float WrapWidth
{
get {
float widthOrHeight = _format.IsVertical ? Height : Width;
if (!_format.IsGenericTypographic) {
widthOrHeight =
((_format.IsVertical ? Height : Width) - (0.463f * FontSize)) / 1.028f;
}
return widthOrHeight;
}
}
internal float WrapHeight {
get {
float widthOrHeight = _format.IsVertical ? Width : Height;
if (!_format.IsGenericTypographic) {
widthOrHeight = (_format.IsVertical ? Width : Height) / 1.08864f;
}
return widthOrHeight;
}
}
internal float Width {
get { return _width; }
}
internal float Height {
get { return _height; }
}
internal StringFormat Format {
get { return _format; }
}
internal float PadWidth (float origWidth)
{
if (Format.IsGenericTypographic)
return origWidth;
//This is a proximity to .NET calculated Width.
return origWidth * 1.028f + 0.463f * FontSize;
}
internal float PadHeight (float origHeight)
{
if (Format.IsGenericTypographic)
return origHeight;
//This is a proximity to .NET calculated Height.
return 1.08864f * origHeight;
}
internal float FontSize
{
get {
return _font.Size;
}
}
internal int CharsConsumed {
get { return _charsConsumed; }
}
internal int CurrentRun {
get { return _currentRun; }
}
internal int CurrentPosition {
get { return _currentPos; }
}
internal float AccumulatedHeight {
get { return _accumulatedHeight; }
}
internal float GetAdvanceBetween(int start, int limit) {
return _measurer.getAdvanceBetween(start, limit);
}
internal geom.AffineTransform Transform {
get { return Format.IsVertical ? Rotate90Transform : Matrix.IdentityTransform.NativeObject; }
}
#endregion
#region Methods
LineLayout NextTextLayoutFromMeasurer() {
if (_accumulatedHeight >= WrapHeight) {
_charsConsumed += _currentPos;
return null;
}
int limit = _measurer.getLineBreakIndex(_currentPos, WrapWidth);
int wordBreak = limit;
if (wordBreak < _currentRun) {
while (wordBreak >= _currentPos && char.IsLetterOrDigit(_s, _charsConsumed + wordBreak))
wordBreak--;
if (wordBreak > _currentPos)
limit = wordBreak + 1;
}
font.TextLayout layout = _measurer.getLayout(_currentPos, limit);
LineLayout lineLayout = new LineLayout(
layout,
this,
_accumulatedHeight);
float lineHeight = PadHeight (lineLayout.Ascent + lineLayout.Descent + lineLayout.Leading);
if (Format.LineLimit && (_accumulatedHeight + lineHeight > WrapHeight)) {
_charsConsumed += _currentPos;
return null;
}
_accumulatedHeight += lineHeight + lineLayout.Leading;
_currentPos = limit;
while (_currentPos < _currentRun) {
if (char.IsWhiteSpace(_s, _charsConsumed + _currentPos))
_currentPos++;
else
break;
}
return lineLayout;
}
internal LineLayout NextLine() {
if (_currentPos < _currentRun && !Format.NoWrap)
return NextTextLayoutFromMeasurer();
_charsConsumed += _currentRun;
if (_charsConsumed >= _s.Length)
return null;
string s;
int lineBreakIndex = _s.IndexOf(NewLine, _charsConsumed);
if (lineBreakIndex >= 0) {
s = _s.Substring(_charsConsumed, lineBreakIndex - _charsConsumed + NewLine.Length);
}
else
s = _s.Substring(_charsConsumed);
_currentRun = s.Length;
_currentPos = 0;
text.AttributedString aS = new text.AttributedString(s);
// TODO: add more attribs according to StringFormat
aS.addAttribute(font.TextAttribute.FONT, _font.NativeObject);
if((_font.Style & FontStyle.Underline) != FontStyle.Regular)
aS.addAttribute(font.TextAttribute.UNDERLINE, font.TextAttribute.UNDERLINE_ON);
if((_font.Style & FontStyle.Strikeout) != FontStyle.Regular)
aS.addAttribute(font.TextAttribute.STRIKETHROUGH, font.TextAttribute.STRIKETHROUGH_ON);
text.AttributedCharacterIterator charIter = aS.getIterator();
_measurer = new font.TextMeasurer(charIter, _frc);
return NextTextLayoutFromMeasurer();
}
internal geom.AffineTransform CalcLineAlignmentTransform() {
if (Format.LineAlignment == StringAlignment.Near)
return null;
float height = WrapHeight;
if (float.IsPositiveInfinity(height))
height = 0;
float shift = height - AccumulatedHeight;
if (height > 0 && shift <= 0)
return null;
if (Format.LineAlignment == StringAlignment.Center)
shift /= 2;
else
if (Format.IsVertical && Format.IsRightToLeft)
return null;
return Format.IsVertical ?
geom.AffineTransform.getTranslateInstance(shift, 0) :
geom.AffineTransform.getTranslateInstance(0, shift);
}
#endregion
}
}

View File

@@ -0,0 +1,42 @@
//
// System.Drawing.TextRenderingHint.cs
//
// Author: Dennis Hayes (dennish@raytek.com)
//
// (C) 2002 Ximian, Inc. http://www.ximian.com
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace System.Drawing.Text {
#if ONLY_1_1
[Serializable]
#endif
public enum TextRenderingHint {
AntiAlias = 4,
AntiAliasGridFit = 3,
ClearTypeGridFit = 5,
SingleBitPerPixel = 2,
SingleBitPerPixelGridFit = 1,
SystemDefault = 0
}
}